mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
prevent moving cursor past last character in prompt modal
This commit is contained in:
committed by
github-actions[bot]
parent
44ee28bb2e
commit
22c7110349
14
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
14
vendor/github.com/jesseduffield/gocui/gui.go
generated
vendored
@ -833,6 +833,20 @@ func (g *Gui) onKey(ev *termbox.Event) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newCx := mx - v.x0 - 1
|
||||
newCy := my - v.y0 - 1
|
||||
// if view is editable don't go further than the furthest character for that line
|
||||
if v.Editable && newCy >= 0 && newCy <= len(v.lines)-1 {
|
||||
lastCharForLine := len(v.lines[newCy])
|
||||
if lastCharForLine < newCx {
|
||||
newCx = lastCharForLine
|
||||
}
|
||||
}
|
||||
if err := v.SetCursor(newCx, newCy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := v.SetCursor(mx-v.x0-1, my-v.y0-1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user