mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget: maintain Editor caret position
Only call layoutCaret when the text layout changes, adjust position for caret movement. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -152,18 +152,6 @@ func (e *editBuffer) dump() {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *editBuffer) move(runes int) {
|
||||
for ; runes < 0 && e.caret > 0; runes++ {
|
||||
_, s := e.runeBefore(e.caret)
|
||||
e.caret -= s
|
||||
}
|
||||
for ; runes > 0 && e.caret < e.len(); runes-- {
|
||||
_, s := e.runeAt(e.caret)
|
||||
e.caret += s
|
||||
}
|
||||
e.dump()
|
||||
}
|
||||
|
||||
func (e *editBuffer) runeBefore(idx int) (rune, int) {
|
||||
if idx > e.gapstart {
|
||||
idx += e.gapLen()
|
||||
|
||||
Reference in New Issue
Block a user