Fix another bug in readline cursor position tracking

This commit is contained in:
Kovid Goyal 2022-11-16 21:18:40 +05:30
parent bdd04f37d6
commit d8574f8f85
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -107,6 +107,7 @@ func (self *Readline) get_screen_lines() []*ScreenLine {
cursor_at_start_of_next_line = false cursor_at_start_of_next_line = false
sl.CursorCell = prompt.Length sl.CursorCell = prompt.Length
sl.CursorTextPos = 0 sl.CursorTextPos = 0
found_cursor = true
} }
ans = append(ans, &sl) ans = append(ans, &sl)
if has_cursor && !found_cursor && offset <= cursor.X && cursor.X <= offset+len(l) { if has_cursor && !found_cursor && offset <= cursor.X && cursor.X <= offset+len(l) {
@ -198,6 +199,7 @@ func (self *Readline) redraw() {
self.loop.QueueWriteString("\r") self.loop.QueueWriteString("\r")
self.loop.MoveCursorHorizontally(cursor_x) self.loop.MoveCursorHorizontally(cursor_x)
self.cursor_y = 0 self.cursor_y = 0
cursor_y -= move_cursor_up_by
if cursor_y > 0 { if cursor_y > 0 {
self.cursor_y = cursor_y - 1 self.cursor_y = cursor_y - 1
} }