1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Bump gocui

This commit is contained in:
Stefan Haller
2024-08-24 10:21:25 +02:00
parent ca9e006cca
commit 59450c7d12
5 changed files with 50 additions and 17 deletions

View File

@ -282,13 +282,7 @@ func (self *TextArea) GoToEndOfLine() {
self.cursor = self.closestNewlineOnRight()
// If the end of line is a soft line break, we need to move left by one so
// that we end up at the last whitespace before the line break. Otherwise
// we'd be at the start of the next line, since the newline character
// doesn't really exist in the real content.
if self.cursor < len(self.content) && self.content[self.cursor] != '\n' {
self.cursor--
}
self.moveLeftFromSoftLineBreak()
}
func (self *TextArea) closestNewlineOnRight() int {
@ -303,6 +297,16 @@ func (self *TextArea) closestNewlineOnRight() int {
return len(self.content)
}
func (self *TextArea) moveLeftFromSoftLineBreak() {
// If the end of line is a soft line break, we need to move left by one so
// that we end up at the last whitespace before the line break. Otherwise
// we'd be at the start of the next line, since the newline character
// doesn't really exist in the real content.
if self.cursor < len(self.content) && self.content[self.cursor] != '\n' {
self.cursor--
}
}
func (self *TextArea) atLineStart() bool {
return self.cursor == 0 ||
(len(self.content) > self.cursor-1 && self.content[self.cursor-1] == '\n')
@ -420,12 +424,16 @@ func (self *TextArea) SetCursor2D(x int, y int) {
for _, r := range self.wrappedContent {
if x <= 0 && y == 0 {
self.cursor = self.wrappedCursorToOrigCursor(newCursor)
if self.wrappedContent[newCursor] == '\n' {
self.moveLeftFromSoftLineBreak()
}
return
}
if r == '\n' {
if y == 0 {
self.cursor = self.wrappedCursorToOrigCursor(newCursor)
self.moveLeftFromSoftLineBreak()
return
}
y--