1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

prevent moving cursor past last character in prompt modal

This commit is contained in:
Jesse Duffield 2020-08-24 20:00:56 +10:00 committed by github-actions[bot]
parent 44ee28bb2e
commit 22c7110349
4 changed files with 18 additions and 2 deletions

2
go.mod
View File

@ -13,7 +13,7 @@ require (
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/gocui v0.3.1-0.20200823073938-1a970a28d894
github.com/jesseduffield/gocui v0.3.1-0.20200824095914-9ea1e384f70d
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect

2
go.sum
View File

@ -96,6 +96,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20200513110002-8cde0b9be542 h1:ezzJM/NZh
github.com/jesseduffield/gocui v0.3.1-0.20200513110002-8cde0b9be542/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
github.com/jesseduffield/gocui v0.3.1-0.20200823073938-1a970a28d894 h1:HEIHfYk0RQ7wxG2ibPGZCYDrL9j6Qzf6jXPdkT8ujlE=
github.com/jesseduffield/gocui v0.3.1-0.20200823073938-1a970a28d894/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
github.com/jesseduffield/gocui v0.3.1-0.20200824095914-9ea1e384f70d h1:8vOu04nW4gmaP/z0A4BsSsytiNkntYH3Z/qj1vbbCf4=
github.com/jesseduffield/gocui v0.3.1-0.20200824095914-9ea1e384f70d/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw=
github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9 h1:iBBk1lhFwjwJw//J2m1yyz9S368GeXQTpMVACTyQMh0=
github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4=
github.com/jesseduffield/termbox-go v0.0.0-20200405031649-4dc645f7e8ba h1:hWBdYchM9nZ2+GldroQQ627ISOC83iRDdpfwY+uyJeI=

View File

@ -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
}

2
vendor/modules.txt vendored
View File

@ -99,7 +99,7 @@ github.com/hashicorp/hcl/json/token
github.com/integrii/flaggy
# github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
github.com/jbenet/go-context/io
# github.com/jesseduffield/gocui v0.3.1-0.20200823073938-1a970a28d894
# github.com/jesseduffield/gocui v0.3.1-0.20200824095914-9ea1e384f70d
## explicit
github.com/jesseduffield/gocui
# github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe