mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
widget: fix moveLines residual x offset calculation
Commit c22138f5f broke it, this change fixes it.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -398,7 +398,7 @@ func (e *Editor) moveLines(distance int, selAct selectionAction) {
|
|||||||
pos := e.closestPosition(combinedPos{lineCol: screenPos{Y: caretStart.lineCol.Y + distance}})
|
pos := e.closestPosition(combinedPos{lineCol: screenPos{Y: caretStart.lineCol.Y + distance}})
|
||||||
pos = e.closestPosition(combinedPos{x: x, y: pos.y})
|
pos = e.closestPosition(combinedPos{x: x, y: pos.y})
|
||||||
e.caret.start = pos.runes
|
e.caret.start = pos.runes
|
||||||
e.caret.xoff = x - caretStart.x
|
e.caret.xoff = x - pos.x
|
||||||
e.updateSelection(selAct)
|
e.updateSelection(selAct)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,14 @@ func TestEditor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that moveLine applies x offsets from previous moves.
|
||||||
|
e.SetText("long line\nshort")
|
||||||
|
e.SetCaret(0, 0)
|
||||||
|
e.moveEnd(selectionClear)
|
||||||
|
e.moveLines(+1, selectionClear)
|
||||||
|
e.moveLines(-1, selectionClear)
|
||||||
|
assertCaret(t, e, 0, utf8.RuneCountInString("long line"), len("long line"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEditorDimensions(t *testing.T) {
|
func TestEditorDimensions(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user