mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget: fix Editor.CaretCoords when scrolled
This commit fixes the position returned by Editor.CaretCoords to account for the scroll position of the editor. Without this change, the returned coordinates can easily overflow the boundaries of the editor widget when it has been scrolled on either axis. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
+1
-1
@@ -908,7 +908,7 @@ func (e *Editor) CaretPos() (line, col int) {
|
||||
// editor itself.
|
||||
func (e *Editor) CaretCoords() f32.Point {
|
||||
caret := e.closestPosition(combinedPos{runes: e.caret.start})
|
||||
return f32.Pt(float32(caret.x)/64, float32(caret.y))
|
||||
return f32.Pt(float32(caret.x)/64-float32(e.scrollOff.X), float32(caret.y-e.scrollOff.Y))
|
||||
}
|
||||
|
||||
// indexPosition returns the latest position from the index no later than pos.
|
||||
|
||||
Reference in New Issue
Block a user