Skip to content

Commit 85afb6e

Browse files
committed
Use StoreVisualX() all over the code
Since we already have the StoreVisualX() helper, use it all over the place instead of setting LastVisualX directly. This will allow us to add more logic to StoreVisualX() add let this extra logic apply everywhere automatically.
1 parent d60413f commit 85afb6e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

internal/action/actions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ func (h *BufPane) InsertNewline() bool {
657657
h.Buf.Remove(buffer.Loc{X: 0, Y: h.Cursor.Y - 1}, buffer.Loc{X: util.CharacterCount(line), Y: h.Cursor.Y - 1})
658658
}
659659
}
660-
h.Cursor.LastVisualX = h.Cursor.GetVisualX()
660+
h.Cursor.StoreVisualX()
661661
h.Relocate()
662662
return true
663663
}
@@ -687,7 +687,7 @@ func (h *BufPane) Backspace() bool {
687687
h.Buf.Remove(loc.Move(-1, h.Buf), loc)
688688
}
689689
}
690-
h.Cursor.LastVisualX = h.Cursor.GetVisualX()
690+
h.Cursor.StoreVisualX()
691691
h.Relocate()
692692
return true
693693
}

internal/buffer/cursor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (c *Cursor) GetCharPosInLine(b []byte, visualPos int) int {
100100
// Start moves the cursor to the start of the line it is on
101101
func (c *Cursor) Start() {
102102
c.X = 0
103-
c.LastVisualX = c.GetVisualX()
103+
c.StoreVisualX()
104104
}
105105

106106
// StartOfText moves the cursor to the first non-whitespace rune of
@@ -131,7 +131,7 @@ func (c *Cursor) IsStartOfText() bool {
131131
// End moves the cursor to the end of the line it is on
132132
func (c *Cursor) End() {
133133
c.X = util.CharacterCount(c.buf.LineBytes(c.Y))
134-
c.LastVisualX = c.GetVisualX()
134+
c.StoreVisualX()
135135
}
136136

137137
// CopySelection copies the user's selection to either "primary"

internal/buffer/eventhandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (eh *EventHandler) DoTextEvent(t *TextEvent, useUndo bool) {
104104
c.OrigSelection[0] = move(c.OrigSelection[0])
105105
c.OrigSelection[1] = move(c.OrigSelection[1])
106106
c.Relocate()
107-
c.LastVisualX = c.GetVisualX()
107+
c.StoreVisualX()
108108
}
109109

110110
if useUndo {

runtime/plugins/comment/comment.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function commentLine(bp, lineN, indentLen)
107107
bp.Cursor.Y = curpos.Y
108108
end
109109
bp.Cursor:Relocate()
110-
bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
110+
bp.Cursor:StoreVisualX()
111111
end
112112

113113
function uncommentLine(bp, lineN, commentRegex)
@@ -135,7 +135,7 @@ function uncommentLine(bp, lineN, commentRegex)
135135
end
136136
end
137137
bp.Cursor:Relocate()
138-
bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
138+
bp.Cursor:StoreVisualX()
139139
end
140140

141141
function toggleCommentLine(bp, lineN, commentRegex)

0 commit comments

Comments
 (0)