diff --git a/go.mod b/go.mod index 0af18042a..37b26b83f 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,6 @@ require ( github.com/gookit/color v1.6.0 github.com/integrii/flaggy v1.8.0 github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c - github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/karimkhaleel/jsonschema v0.0.0-20231001195015-d933f0d94ea3 diff --git a/go.sum b/go.sum index 1eca13f8b..e108704c1 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,6 @@ github.com/invopop/jsonschema v0.10.0 h1:c1ktzNLBun3LyQQhyty5WE3lulbOdIIyOVlkmDL github.com/invopop/jsonschema v0.10.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c h1:tC2PaiisXAC5sOjDPfMArSnbswDObtCssx+xn28edX4= github.com/jesseduffield/generics v0.0.0-20250517122708-b0b4a53a6f5c/go.mod h1:F2fEBk0ddf6ixrBrJjY7phfQ3hL9rXG0uSjvwYe50bE= -github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 h1:LEZwOrBm9S+4lRlXpoz+RSzSvhOVE+6v/Rk+A7Kg00Q= -github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980/go.mod h1:lQCd2TvvNXVKFBowy4A7xxZbUp+1KEiGs4j0Q5Zt9gQ= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5/go.mod h1:qxN4mHOAyeIDLP7IK7defgPClM/z1Kze8VVQiaEjzsQ= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= diff --git a/pkg/commands/git_commands/remote.go b/pkg/commands/git_commands/remote.go index cfcb85091..3b27730fc 100644 --- a/pkg/commands/git_commands/remote.go +++ b/pkg/commands/git_commands/remote.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go index d64a0910c..0400b4e26 100644 --- a/pkg/commands/git_commands/sync.go +++ b/pkg/commands/git_commands/sync.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type SyncCommands struct { diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go index fdc44a6b9..6a7702586 100644 --- a/pkg/commands/git_commands/sync_test.go +++ b/pkg/commands/git_commands/sync_test.go @@ -3,8 +3,8 @@ package git_commands import ( "testing" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/commands/git_commands/tag.go b/pkg/commands/git_commands/tag.go index 1e9b449b1..4d15027e1 100644 --- a/pkg/commands/git_commands/tag.go +++ b/pkg/commands/git_commands/tag.go @@ -3,8 +3,8 @@ package git_commands import ( "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type TagCommands struct { diff --git a/pkg/commands/oscommands/cmd_obj.go b/pkg/commands/oscommands/cmd_obj.go index 24d2ca511..0df6ed43c 100644 --- a/pkg/commands/oscommands/cmd_obj.go +++ b/pkg/commands/oscommands/cmd_obj.go @@ -4,7 +4,7 @@ import ( "os/exec" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" "github.com/sasha-s/go-deadlock" ) diff --git a/pkg/commands/oscommands/cmd_obj_runner_test.go b/pkg/commands/oscommands/cmd_obj_runner_test.go index 74e3a1985..ffddfaad1 100644 --- a/pkg/commands/oscommands/cmd_obj_runner_test.go +++ b/pkg/commands/oscommands/cmd_obj_runner_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/commands/oscommands/cmd_obj_test.go b/pkg/commands/oscommands/cmd_obj_test.go index b135f1b74..269b5dac2 100644 --- a/pkg/commands/oscommands/cmd_obj_test.go +++ b/pkg/commands/oscommands/cmd_obj_test.go @@ -4,7 +4,7 @@ import ( "os/exec" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func TestCmdObjToString(t *testing.T) { diff --git a/pkg/config/keynames.go b/pkg/config/keynames.go index bb9756b43..00dc158fc 100644 --- a/pkg/config/keynames.go +++ b/pkg/config/keynames.go @@ -4,7 +4,7 @@ import ( "strings" "unicode/utf8" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/vendor/github.com/jesseduffield/gocui/AUTHORS b/pkg/gocui/AUTHORS similarity index 100% rename from vendor/github.com/jesseduffield/gocui/AUTHORS rename to pkg/gocui/AUTHORS diff --git a/vendor/github.com/jesseduffield/gocui/CHANGES_tcell.md b/pkg/gocui/CHANGES_tcell.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CHANGES_tcell.md rename to pkg/gocui/CHANGES_tcell.md diff --git a/vendor/github.com/jesseduffield/gocui/CODE_OF_CONDUCT.md b/pkg/gocui/CODE_OF_CONDUCT.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CODE_OF_CONDUCT.md rename to pkg/gocui/CODE_OF_CONDUCT.md diff --git a/vendor/github.com/jesseduffield/gocui/CONTRIBUTING.md b/pkg/gocui/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/CONTRIBUTING.md rename to pkg/gocui/CONTRIBUTING.md diff --git a/vendor/github.com/jesseduffield/gocui/LICENSE b/pkg/gocui/LICENSE similarity index 100% rename from vendor/github.com/jesseduffield/gocui/LICENSE rename to pkg/gocui/LICENSE diff --git a/vendor/github.com/jesseduffield/gocui/README.md b/pkg/gocui/README.md similarity index 100% rename from vendor/github.com/jesseduffield/gocui/README.md rename to pkg/gocui/README.md diff --git a/vendor/github.com/jesseduffield/gocui/attribute.go b/pkg/gocui/attribute.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/attribute.go rename to pkg/gocui/attribute.go diff --git a/vendor/github.com/jesseduffield/gocui/doc.go b/pkg/gocui/doc.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/doc.go rename to pkg/gocui/doc.go diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/pkg/gocui/edit.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/edit.go rename to pkg/gocui/edit.go diff --git a/vendor/github.com/jesseduffield/gocui/escape.go b/pkg/gocui/escape.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/escape.go rename to pkg/gocui/escape.go diff --git a/pkg/gocui/escape_test.go b/pkg/gocui/escape_test.go new file mode 100644 index 000000000..0073463c4 --- /dev/null +++ b/pkg/gocui/escape_test.go @@ -0,0 +1,159 @@ +package gocui + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestParseOne(t *testing.T) { + var ei *escapeInterpreter + + ei = newEscapeInterpreter(OutputNormal) + isEscape, err := ei.parseOne([]byte{'a'}) + assert.Equal(t, false, isEscape) + assert.NoError(t, err) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[0K") + _, ok := ei.instruction.(eraseInLineFromCursor) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[K") + _, ok = ei.instruction.(eraseInLineFromCursor) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b[1K") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b(B") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b)0") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b*A") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) + + ei = newEscapeInterpreter(OutputNormal) + parseEscRunes(t, ei, "\x1b+K") + _, ok = ei.instruction.(noInstruction) + assert.Equal(t, true, ok) +} + +func TestParseOneColours(t *testing.T) { + scenarios := []struct { + outputMode OutputMode + input string + expectedFg Attribute + expectedBg Attribute + }{ + {OutputNormal, "\x1b[30m", ColorBlack, ColorDefault}, + {OutputNormal, "\x1b[31m", ColorRed, ColorDefault}, + {OutputNormal, "\x1b[32m", ColorGreen, ColorDefault}, + {OutputNormal, "\x1b[33m", ColorYellow, ColorDefault}, + {OutputNormal, "\x1b[34m", ColorBlue, ColorDefault}, + {OutputNormal, "\x1b[35m", ColorMagenta, ColorDefault}, + {OutputNormal, "\x1b[36m", ColorCyan, ColorDefault}, + {OutputNormal, "\x1b[37m", ColorWhite, ColorDefault}, + {OutputNormal, "\x1b[40m", ColorDefault, ColorBlack}, + {OutputNormal, "\x1b[41m", ColorDefault, ColorRed}, + {OutputNormal, "\x1b[42m", ColorDefault, ColorGreen}, + {OutputNormal, "\x1b[43m", ColorDefault, ColorYellow}, + {OutputNormal, "\x1b[44m", ColorDefault, ColorBlue}, + {OutputNormal, "\x1b[45m", ColorDefault, ColorMagenta}, + {OutputNormal, "\x1b[46m", ColorDefault, ColorCyan}, + {OutputNormal, "\x1b[47m", ColorDefault, ColorWhite}, + {OutputNormal, "\x1b[47;31m", ColorRed, ColorWhite}, + {OutputNormal, "\x1b[90m", Get256Color(8), ColorDefault}, + {OutputNormal, "\x1b[91m", Get256Color(9), ColorDefault}, + {OutputNormal, "\x1b[92m", Get256Color(10), ColorDefault}, + {OutputNormal, "\x1b[93m", Get256Color(11), ColorDefault}, + {OutputNormal, "\x1b[94m", Get256Color(12), ColorDefault}, + {OutputNormal, "\x1b[95m", Get256Color(13), ColorDefault}, + {OutputNormal, "\x1b[96m", Get256Color(14), ColorDefault}, + {OutputNormal, "\x1b[97m", Get256Color(15), ColorDefault}, + {OutputNormal, "\x1b[100m", ColorDefault, Get256Color(8)}, + {OutputNormal, "\x1b[101m", ColorDefault, Get256Color(9)}, + {OutputNormal, "\x1b[102m", ColorDefault, Get256Color(10)}, + {OutputNormal, "\x1b[103m", ColorDefault, Get256Color(11)}, + {OutputNormal, "\x1b[104m", ColorDefault, Get256Color(12)}, + {OutputNormal, "\x1b[105m", ColorDefault, Get256Color(13)}, + {OutputNormal, "\x1b[106m", ColorDefault, Get256Color(14)}, + {OutputNormal, "\x1b[107m", ColorDefault, Get256Color(15)}, + {Output256, "\x1b[38;5;32m", Get256Color(32), ColorDefault}, + {OutputTrue, "\x1b[38;5;32m", Get256Color(32), ColorDefault}, + {OutputTrue, "\x1b[38;2;50;103;205m", NewRGBColor(50, 103, 205), ColorDefault}, + {Output256, "\x1b[48;5;32m", ColorDefault, Get256Color(32)}, + {OutputTrue, "\x1b[48;5;32m", ColorDefault, Get256Color(32)}, + {OutputTrue, "\x1b[48;2;50;103;205m", ColorDefault, NewRGBColor(50, 103, 205)}, + {OutputTrue, "\x1b[1;95;48;2;255;224;224m", Get256Color(13), NewRGBColor(255, 224, 224)}, + } + + for _, scenario := range scenarios { + ei := newEscapeInterpreter(scenario.outputMode) + parseEscRunes(t, ei, scenario.input) + assert.Equal(t, scenario.expectedFg, ei.curFgColor&AttrColorBits) + assert.Equal(t, scenario.expectedBg, ei.curBgColor) + } + + // resetting colours + scenarios = []struct { + outputMode OutputMode + input string + expectedFg Attribute + expectedBg Attribute + }{ + {OutputNormal, "\x1b[39m", ColorDefault, ColorRed}, + {OutputNormal, "\x1b[49m", ColorRed, ColorDefault}, + {OutputNormal, "\x1b[0m", ColorDefault, ColorDefault}, + } + + for _, scenario := range scenarios { + ei := newEscapeInterpreter(scenario.outputMode) + ei.curFgColor = ColorRed + ei.curBgColor = ColorRed + parseEscRunes(t, ei, scenario.input) + assert.Equal(t, scenario.expectedFg, ei.curFgColor) + assert.Equal(t, scenario.expectedBg, ei.curBgColor) + } + + // setting attributes + attrScenarios := []struct { + outputMode OutputMode + input string + expectedAttr Attribute + }{ + {OutputNormal, "\x1b[1m", AttrBold}, + {OutputNormal, "\x1b[2m", AttrDim}, + {OutputNormal, "\x1b[3m", AttrItalic}, + {OutputNormal, "\x1b[4m", AttrUnderline}, + {OutputNormal, "\x1b[5m", AttrBlink}, + {OutputNormal, "\x1b[7m", AttrReverse}, + {OutputNormal, "\x1b[9m", AttrStrikeThrough}, + } + + for _, scenario := range attrScenarios { + ei := newEscapeInterpreter(scenario.outputMode) + parseEscRunes(t, ei, scenario.input) + style := ei.curFgColor & AttrStyleBits + assert.Equal(t, scenario.expectedAttr, style) + } +} + +func parseEscRunes(t *testing.T, ei *escapeInterpreter, runes string) { + for _, b := range []byte(runes) { + isEscape, err := ei.parseOne([]byte{b}) + assert.Equal(t, true, isEscape) + assert.NoError(t, err) + } +} diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/pkg/gocui/gui.go similarity index 97% rename from vendor/github.com/jesseduffield/gocui/gui.go rename to pkg/gocui/gui.go index 0d97e280b..0db418c67 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/pkg/gocui/gui.go @@ -8,7 +8,6 @@ import ( "context" standardErrors "errors" "runtime" - "slices" "strings" "sync" "time" @@ -25,15 +24,6 @@ type OutputMode int const DOUBLE_CLICK_THRESHOLD = 500 * time.Millisecond var ( - // ErrAlreadyBlacklisted is returned when the keybinding is already blacklisted. - ErrAlreadyBlacklisted = standardErrors.New("keybind already blacklisted") - - // ErrBlacklisted is returned when the keybinding being parsed / used is blacklisted. - ErrBlacklisted = standardErrors.New("keybind blacklisted") - - // ErrNotBlacklisted is returned when a keybinding being whitelisted is not blacklisted. - ErrNotBlacklisted = standardErrors.New("keybind not blacklisted") - // ErrNoSuchKeybind is returned when the keybinding being parsed does not exist. ErrNoSuchKeybind = standardErrors.New("no such keybind") @@ -155,7 +145,6 @@ type Gui struct { maxX, maxY int outputMode OutputMode stop chan struct{} - blacklist []Key // BgColor and FgColor allow to configure the background and foreground // colors of the GUI. @@ -573,10 +562,6 @@ func (g *Gui) SetKeybinding(viewname string, key any, mod Modifier, handler func return err } - if g.isBlacklisted(k) { - return ErrBlacklisted - } - kb = newKeybinding(viewname, k, ch, mod, handler) g.keybindings = append(g.keybindings, kb) return nil @@ -632,26 +617,6 @@ func (g *Gui) SetViewClickBinding(binding *ViewMouseBinding) error { return nil } -// BlackListKeybinding adds a keybinding to the blacklist -func (g *Gui) BlacklistKeybinding(k Key) error { - if slices.Contains(g.blacklist, k) { - return ErrAlreadyBlacklisted - } - g.blacklist = append(g.blacklist, k) - return nil -} - -// WhiteListKeybinding removes a keybinding from the blacklist -func (g *Gui) WhitelistKeybinding(k Key) error { - for i, j := range g.blacklist { - if j == k { - g.blacklist = append(g.blacklist[:i], g.blacklist[i+1:]...) - return nil - } - } - return ErrNotBlacklisted -} - func (g *Gui) SetFocusHandler(handler func(bool) error) { g.focusHandler = handler } @@ -1616,10 +1581,6 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) error { // execKeybinding executes a given keybinding func (g *Gui) execKeybinding(v *View, kb *keybinding) error { - if g.isBlacklisted(kb.key) { - return nil - } - if err := kb.handler(g, v); err != nil { return err } @@ -1665,11 +1626,6 @@ func (g *Gui) StartTicking(ctx context.Context) { }() } -// isBlacklisted reports whether the key is blacklisted -func (g *Gui) isBlacklisted(k Key) bool { - return slices.Contains(g.blacklist, k) -} - func (g *Gui) Suspend() error { g.suspendedMutex.Lock() defer g.suspendedMutex.Unlock() diff --git a/vendor/github.com/jesseduffield/gocui/gui_others.go b/pkg/gocui/gui_others.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/gui_others.go rename to pkg/gocui/gui_others.go diff --git a/vendor/github.com/jesseduffield/gocui/gui_windows.go b/pkg/gocui/gui_windows.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/gui_windows.go rename to pkg/gocui/gui_windows.go diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/pkg/gocui/keybinding.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/keybinding.go rename to pkg/gocui/keybinding.go diff --git a/vendor/github.com/jesseduffield/gocui/loader.go b/pkg/gocui/loader.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/loader.go rename to pkg/gocui/loader.go diff --git a/vendor/github.com/jesseduffield/gocui/scrollbar.go b/pkg/gocui/scrollbar.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/scrollbar.go rename to pkg/gocui/scrollbar.go diff --git a/pkg/gocui/scrollbar_test.go b/pkg/gocui/scrollbar_test.go new file mode 100644 index 000000000..63db4bb9a --- /dev/null +++ b/pkg/gocui/scrollbar_test.go @@ -0,0 +1,114 @@ +package gocui + +import "testing" + +func TestCalcScrollbar(t *testing.T) { + tests := []struct { + testName string + listSize int + pageSize int + position int + scrollAreaSize int + + expectedStart int + expectedHeight int + }{ + { + testName: "page size greater than list size", + listSize: 5, + pageSize: 10, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 20, + }, + { + testName: "page size matches list size", + listSize: 10, + pageSize: 10, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 20, + }, + { + testName: "page size half of list size", + listSize: 10, + pageSize: 5, + position: 0, + scrollAreaSize: 20, + + expectedStart: 0, + expectedHeight: 10, + }, + { + testName: "page size half of list size at scroll end", + listSize: 10, + pageSize: 5, + position: 5, + scrollAreaSize: 20, + + expectedStart: 10, + expectedHeight: 10, + }, + { + testName: "page size third of list size having scrolled half the way", + listSize: 15, + // Recall that my max position is listSize - pageSize i.e 15 - 5 i.e. 10. + // So if I've scrolled to position 5 that means I've done one page and I've got + // one page to go which means by scrollbar should take up a third of the available + // space and appear in the centre of the scrollbar area + pageSize: 5, + position: 5, + scrollAreaSize: 21, + + expectedStart: 7, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled the full way", + listSize: 15, + pageSize: 5, + position: 10, + scrollAreaSize: 21, + + expectedStart: 14, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled by one", + listSize: 15, + pageSize: 5, + position: 1, + scrollAreaSize: 21, + + expectedStart: 2, + expectedHeight: 7, + }, + { + testName: "page size third of list size having scrolled up from the bottom by one", + listSize: 15, + pageSize: 5, + position: 9, + scrollAreaSize: 21, + + expectedStart: 12, + expectedHeight: 7, + }, + } + + for _, test := range tests { + t.Run(test.testName, func(t *testing.T) { + start, height := calcScrollbar(test.listSize, test.pageSize, test.position, test.scrollAreaSize) + if start != test.expectedStart { + t.Errorf("expected start to be %d, got %d", test.expectedStart, start) + } + + if height != test.expectedHeight { + t.Errorf("expected height to be %d, got %d", test.expectedHeight, height) + } + }) + } +} diff --git a/vendor/github.com/jesseduffield/gocui/task.go b/pkg/gocui/task.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/task.go rename to pkg/gocui/task.go diff --git a/vendor/github.com/jesseduffield/gocui/task_manager.go b/pkg/gocui/task_manager.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/task_manager.go rename to pkg/gocui/task_manager.go diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/pkg/gocui/tcell_driver.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/tcell_driver.go rename to pkg/gocui/tcell_driver.go diff --git a/vendor/github.com/jesseduffield/gocui/text_area.go b/pkg/gocui/text_area.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/text_area.go rename to pkg/gocui/text_area.go diff --git a/pkg/gocui/text_area_test.go b/pkg/gocui/text_area_test.go new file mode 100644 index 000000000..618e1a02e --- /dev/null +++ b/pkg/gocui/text_area_test.go @@ -0,0 +1,1043 @@ +package gocui + +import ( + "reflect" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestTextArea(t *testing.T) { + tests := []struct { + actions func(*TextArea) + wrapWidth int + expectedContent string + expectedCursor int + expectedClipboard string + }{ + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + }, + expectedContent: "abc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + }, + expectedContent: "a\nc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd") + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("a字cd") + }, + expectedContent: "a字cd", + expectedCursor: 6, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.BackSpaceChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.BackSpaceChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.BackSpaceChar() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.DeleteChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.DeleteChar() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + textarea.DeleteChar() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteChar() + }, + expectedContent: "ac", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.MoveCursorLeft() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + }, + expectedContent: "a", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + }, + expectedContent: "ab", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.MoveCursorRight() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorRight() + }, + expectedContent: "a", + expectedCursor: 1, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + textarea.MoveCursorRight() + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("漢") + textarea.TypeCharacter("字") + textarea.MoveCursorLeft() + }, + expectedContent: "漢字", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.ToggleOverwrite() + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.ToggleOverwrite() + textarea.TypeCharacter("d") + }, + expectedContent: "adc", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa\nbbb") + textarea.MoveLeftWord() + }, + expectedContent: "aaa\nbbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveLeftWord() + }, + wrapWidth: 4, + expectedContent: "aaa bbb", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb\n") + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb\n", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveLeftWord() + textarea.MoveLeftWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa") + textarea.GoToStartOfLine() + textarea.MoveLeftWord() + }, + expectedContent: "aaa", + expectedCursor: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa\nbbb") + textarea.GoToStartOfLine() + textarea.MoveCursorLeft() + textarea.MoveRightWord() + }, + expectedContent: "aaa\nbbb", + expectedCursor: 4, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveCursorLeft() + textarea.MoveRightWord() + }, + wrapWidth: 4, + expectedContent: "aaa bbb", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb") + textarea.GoToStartOfLine() + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb", + expectedCursor: 3, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("aaa bbb\n") + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + textarea.MoveRightWord() + textarea.MoveRightWord() + }, + expectedContent: "aaa bbb\n", + expectedCursor: 7, + }, + { + actions: func(textarea *TextArea) { + // overwrite mode acts same as normal mode when cursor is at the end + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("c") + textarea.ToggleOverwrite() + textarea.TypeCharacter("d") + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.DeleteToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.DeleteToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "ab", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.DeleteToStartOfLine() + }, + expectedContent: "ab\n", + expectedCursor: 3, + expectedClipboard: "cd", + }, + { + actions: func(textarea *TextArea) { + textarea.GoToStartOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "a", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToStartOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.GoToEndOfLine() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("a") + textarea.TypeCharacter("b") + textarea.TypeCharacter("\n") + textarea.TypeCharacter("c") + textarea.TypeCharacter("d") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.GoToEndOfLine() + }, + expectedContent: "ab\ncd", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.SetCursor2D(10, 10) + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.SetCursor2D(-1, -1) + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + textarea.SetCursor2D(0, 0) + }, + expectedContent: "ab\ncd", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + textarea.SetCursor2D(2, 0) + }, + expectedContent: "ab\ncd", + expectedCursor: 2, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd\nef") + textarea.SetCursor2D(2, 1) + }, + expectedContent: "ab\ncd\nef", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd\n\nijkl") + textarea.MoveCursorUp() + }, + expectedContent: "abcd\n\nijkl", + expectedCursor: 5, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcdef\n老老老") + textarea.MoveCursorLeft() + textarea.MoveCursorUp() + }, + expectedContent: "abcdef\n老老老", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcdef\n老老老") + textarea.MoveCursorUp() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorDown() + }, + expectedContent: "abcdef\n老老老", + expectedCursor: 13, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd\nef") + textarea.MoveCursorUp() + textarea.GoToEndOfLine() + textarea.MoveCursorDown() + }, + expectedContent: "abcd\nef", + expectedCursor: 7, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abcd") + textarea.MoveCursorUp() + }, + expectedContent: "abcd", + expectedCursor: 4, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abcdefg`) + textarea.Clear() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abcdefg`) + textarea.Clear() + }, + expectedContent: "", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.MoveCursorLeft() + textarea.BackSpaceWord() + }, + expectedContent: "abc f", + expectedCursor: 4, + expectedClipboard: "de", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def `) + textarea.BackSpaceWord() + }, + expectedContent: "abc ", + expectedCursor: 5, + expectedClipboard: "def ", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc def\nghi") + textarea.BackSpaceWord() + }, + expectedContent: "abc def\n", + expectedCursor: 8, + expectedClipboard: "ghi", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc def\nghi") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.BackSpaceWord() + }, + expectedContent: "abc defghi", + expectedCursor: 7, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc(def)`) + textarea.BackSpaceWord() + }, + expectedContent: "abc(def", + expectedCursor: 7, + expectedClipboard: ")", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc(def`) + textarea.BackSpaceWord() + }, + expectedContent: "abc(", + expectedCursor: 4, + expectedClipboard: "def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc`) + textarea.GoToStartOfLine() + textarea.BackSpaceWord() + }, + expectedContent: "abc", + expectedCursor: 0, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc`) + textarea.Yank() + }, + expectedContent: "abc", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.DeleteToStartOfLine() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defabc def", + expectedCursor: 14, + expectedClipboard: "abc def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc\ndef") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorUp() + textarea.DeleteToEndOfLine() + }, + expectedContent: "a\ndef", + expectedCursor: 1, + expectedClipboard: "bc", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc\ndef") + textarea.MoveCursorUp() + textarea.DeleteToEndOfLine() + }, + expectedContent: "abcdef", + expectedCursor: 3, + expectedClipboard: "", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.BackSpaceWord() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defdef", + expectedCursor: 10, + expectedClipboard: "def", + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString(`abc def`) + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.DeleteToEndOfLine() + textarea.Yank() + textarea.Yank() + }, + expectedContent: "abc defef", + expectedCursor: 9, + expectedClipboard: "ef", + }, + } + + for i, test := range tests { + t.Run(strconv.Itoa(i+1), func(t *testing.T) { + textarea := &TextArea{} + if test.wrapWidth > 0 { + textarea.AutoWrap = true + textarea.AutoWrapWidth = test.wrapWidth + } + test.actions(textarea) + assert.EqualValues(t, test.expectedContent, textarea.GetUnwrappedContent()) + assert.EqualValues(t, test.expectedCursor, textarea.cursor) + assert.EqualValues(t, test.expectedClipboard, textarea.clipboard) + }) + } +} + +func TestGetCursorXY(t *testing.T) { + tests := []struct { + actions func(*TextArea) + wrapWidth int + expectedX int + expectedY int + }{ + { + actions: func(textarea *TextArea) { + // do nothing + }, + expectedX: 0, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n") + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\na") + }, + expectedX: 1, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n") + textarea.MoveCursorUp() + }, + expectedX: 0, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("\n\n") + textarea.MoveCursorUp() + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\ncd") + }, + expectedX: 2, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n") + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n") + textarea.MoveCursorLeft() + }, + expectedX: 2, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n\n") + }, + expectedX: 0, + expectedY: 2, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("ab\n\n") + textarea.MoveCursorLeft() + }, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeCharacter("漢") + textarea.TypeCharacter("字") + }, + expectedX: 4, + expectedY: 0, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 1, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 0, + expectedY: 1, + }, + { + actions: func(textarea *TextArea) { + textarea.TypeString("abc de") + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + textarea.MoveCursorLeft() + }, + wrapWidth: 4, + expectedX: 3, + expectedY: 0, + }, + } + + for i, test := range tests { + t.Run(strconv.Itoa(i+1), func(t *testing.T) { + textarea := &TextArea{} + if test.wrapWidth > 0 { + textarea.AutoWrap = true + textarea.AutoWrapWidth = test.wrapWidth + } + test.actions(textarea) + x, y := textarea.GetCursorXY() + assert.EqualValues(t, test.expectedX, x) + assert.EqualValues(t, test.expectedY, y) + + // As a sanity check, test that setting the cursor back to (x, y) results in the same cursor position: + cursor := textarea.cursor + textarea.SetCursor2D(x, y) + assert.EqualValues(t, cursor, textarea.cursor) + }) + } +} + +func Test_AutoWrapContent(t *testing.T) { + tests := []struct { + name string + content string + autoWrapWidth int + expectedWrappedContent string + expectedSoftLineBreaks []int + }{ + { + name: "empty content", + content: "", + autoWrapWidth: 7, + expectedWrappedContent: "", + expectedSoftLineBreaks: []int{}, + }, + { + name: "no wrapping necessary", + content: "abcde", + autoWrapWidth: 7, + expectedWrappedContent: "abcde", + expectedSoftLineBreaks: []int{}, + }, + { + name: "wrap at whitespace", + content: "abcde xyz", + autoWrapWidth: 7, + expectedWrappedContent: "abcde \nxyz", + expectedSoftLineBreaks: []int{6}, + }, + { + name: "take wide characters into account", + content: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 x y", // the flag has a width of 2 + autoWrapWidth: 7, + expectedWrappedContent: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 x \ny", + expectedSoftLineBreaks: []int{60}, + }, + { + name: "take wide characters into account at line end", + content: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿", // the flag has a width of 2 + autoWrapWidth: 7, + expectedWrappedContent: "🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 \n🏴󠁧󠁢󠁥󠁮󠁧󠁿", + expectedSoftLineBreaks: []int{58}, + }, + { + name: "lots of whitespace is preserved at end of line", + content: "abcde xyz", + autoWrapWidth: 7, + expectedWrappedContent: "abcde \nxyz", + expectedSoftLineBreaks: []int{11}, + }, + { + name: "don't wrap inside long word when there's no whitespace", + content: "abc defghijklmn opq", + autoWrapWidth: 7, + expectedWrappedContent: "abc \ndefghijklmn \nopq", + expectedSoftLineBreaks: []int{4, 16}, + }, + { + name: "don't break at space after footnote symbol", + content: "abc\n[1]: https://long/link\ndef", + autoWrapWidth: 7, + expectedWrappedContent: "abc\n[1]: https://long/link\ndef", + expectedSoftLineBreaks: []int{}, + }, + { + name: "don't break at space after footnote symbol at soft line start", + content: "abc def [1]: https://long/link\nghi", + autoWrapWidth: 7, + expectedWrappedContent: "abc def \n[1]: https://long/link\nghi", + expectedSoftLineBreaks: []int{8}, + }, + { + name: "do break at subsequent space after footnote symbol", + content: "abc\n[1]: normal text follows\ndef", + autoWrapWidth: 7, + expectedWrappedContent: "abc\n[1]: normal \ntext \nfollows\ndef", + expectedSoftLineBreaks: []int{16, 21}, + }, + { + name: "don't break at space after trailer", + content: "abc\nSigned-off-by: John Doe \nCo-authored-by: Jane Smith \n", + autoWrapWidth: 10, + expectedWrappedContent: "abc\nSigned-off-by: John Doe \nCo-authored-by: Jane Smith \n", + expectedSoftLineBreaks: []int{}, + }, + { + name: "do break at space after trailer if there is no space after the colon", + content: "abc\nSigned-off-by:John Doe \n", + autoWrapWidth: 10, + expectedWrappedContent: "abc\nSigned-off-by:John \nDoe \n\n", + expectedSoftLineBreaks: []int{23, 27}, + }, + { + name: "hard line breaks", + content: "abc\ndef\n", + autoWrapWidth: 7, + expectedWrappedContent: "abc\ndef\n", + expectedSoftLineBreaks: []int{}, + }, + { + name: "mixture of hard and soft line breaks", + content: "abc def ghi jkl mno\npqr stu vwx yz\n", + autoWrapWidth: 7, + expectedWrappedContent: "abc def \nghi jkl \nmno\npqr stu \nvwx yz\n", + expectedSoftLineBreaks: []int{8, 16, 28}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + textArea := &TextArea{content: tt.content, AutoWrapWidth: tt.autoWrapWidth, AutoWrap: true} + cells, softLineBreakIndices := contentToCells(tt.content, tt.autoWrapWidth) + textArea.cells = cells + if !reflect.DeepEqual(textArea.GetContent(), tt.expectedWrappedContent) { + t.Errorf("autoWrapContentImpl() wrappedContent = %v, expected %v", textArea.GetContent(), tt.expectedWrappedContent) + } + if !reflect.DeepEqual(softLineBreakIndices, tt.expectedSoftLineBreaks) { + t.Errorf("autoWrapContentImpl() softLineBreakIndices = %v, expected %v", softLineBreakIndices, tt.expectedSoftLineBreaks) + } + + // As a sanity check, run through all characters of the original content, + // convert the cursor to the wrapped cursor, and check that the character + // in the wrapped content at that position is the same: + origCursor := 0 + for _, chr := range stringToGraphemes(tt.content) { + wrappedIndex := textArea.contentCursorToCellCursor(origCursor) + if chr != textArea.cells[wrappedIndex].char { + t.Errorf("Runes in orig content and wrapped content don't match at %d: expected %v, got %v", origCursor, chr, textArea.cells[wrappedIndex].char) + } + + // Also, check that converting the wrapped position back to the + // orig position yields the original value again: + origIndexAgain := textArea.cellCursorToContentCursor(wrappedIndex) + if origCursor != origIndexAgain { + t.Errorf("wrappedCursorToOrigCursor doesn't yield original position: expected %d, got %d", origCursor, origIndexAgain) + } + + origCursor += len(chr) + } + }) + } +} + +var testContent string = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Quisque vehicula mi at elit pellentesque, eu pulvinar ligula molestie. +In vitae orci vitae elit fermentum lobortis sed in nisi. +Nam non odio nisi. +Donec vitae elit enim. +Pellentesque faucibus dolor at metus elementum sollicitudin. +Mauris eu orci vel odio ornare feugiat eget ac nisl. +Nam at dolor erat. +Integer sit amet rutrum lectus, mollis pretium sapien. +Maecenas ligula ipsum, congue vitae rhoncus eget, volutpat at quam. +Donec ac ultricies tortor, sit amet sollicitudin urna. +Integer porta ornare diam a imperdiet. +Praesent vulputate mi turpis, in porttitor diam commodo a. +Donec ut enim ligula. + +[Thïs-is-not-à-fôôtnöte]: https://example.com/footnote + +Sïgned-öff-by: This is not a trailer + +[1]: This is a footnote + +Signed-off-by: John Doe +` + +func BenchmarkTypeCharacter(b *testing.B) { + textArea := &TextArea{content: testContent, AutoWrapWidth: 72, AutoWrap: true} + textArea.SetCursor2D(0, 0) + + b.ResetTimer() + for b.Loop() { + textArea.TypeCharacter("a") + } +} diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/pkg/gocui/view.go similarity index 100% rename from vendor/github.com/jesseduffield/gocui/view.go rename to pkg/gocui/view.go diff --git a/pkg/gocui/view_test.go b/pkg/gocui/view_test.go new file mode 100644 index 000000000..a7023be43 --- /dev/null +++ b/pkg/gocui/view_test.go @@ -0,0 +1,415 @@ +// Copyright 2014 The gocui Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gocui + +import ( + "strings" + "testing" + + "github.com/rivo/uniseg" + "github.com/stretchr/testify/assert" +) + +func TestWriteString(t *testing.T) { + tests := []struct { + existingLines []string + stringsToWrite []string + expectedLines [][]string + }{ + { + []string{}, + []string{""}, + [][]string{{}}, + }, + { + []string{}, + []string{"1\n"}, + [][]string{{"1", ""}}, + }, + { + []string{}, + []string{"1\n", "2\n"}, + [][]string{{"1", ""}, {"2", ""}}, + }, + { + []string{"a"}, + []string{"1\n"}, + [][]string{{"1", ""}}, + }, + { + []string{"a\x00"}, + []string{"1\n"}, + [][]string{{"1", "\x00"}}, + }, + { + []string{"ab"}, + []string{"1\n"}, + [][]string{{"1", "b"}}, + }, + { + []string{"abc"}, + []string{"1\n"}, + [][]string{{"1", "b", "c"}}, + }, + { + []string{}, + []string{"1\r"}, + [][]string{{"1", ""}}, + }, + { + []string{"a"}, + []string{"1\r"}, + [][]string{{"1", ""}}, + }, + { + []string{"a\x00"}, + []string{"1\r"}, + [][]string{{"1", "\x00"}}, + }, + { + []string{"ab"}, + []string{"1\r"}, + [][]string{{"1", "b"}}, + }, + { + []string{"abc"}, + []string{"1\r"}, + [][]string{{"1", "b", "c"}}, + }, + } + + for _, test := range tests { + v := NewView("name", 0, 0, 10, 10, OutputNormal) + for _, l := range test.existingLines { + v.lines = append(v.lines, stringToCells(l)) + } + for _, s := range test.stringsToWrite { + v.writeString(s) + } + var resultingLines [][]string + for _, l := range v.lines { + resultingLines = append(resultingLines, cellsToStrings(l)) + } + assert.Equal(t, test.expectedLines, resultingLines) + } +} + +func TestUpdatedCursorAndOrigin(t *testing.T) { + tests := []struct { + prevOrigin int + size int + cursor int + expectedCursor int + expectedOrigin int + }{ + {0, 10, 0, 0, 0}, + {0, 10, 9, 9, 0}, + {0, 10, 10, 9, 1}, + {0, 10, 19, 9, 10}, + {0, 10, 20, 9, 11}, + {20, 10, 19, 0, 19}, + {20, 10, 25, 5, 20}, + } + + for _, test := range tests { + cursor, origin := updatedCursorAndOrigin(test.prevOrigin, test.size, test.cursor) + assert.EqualValues(t, test.expectedCursor, cursor, "Cursor is wrong") + assert.EqualValues(t, test.expectedOrigin, origin, "Origin in wrong") + } +} + +func TestAutoRenderingHyperlinks(t *testing.T) { + v := NewView("name", 0, 0, 10, 10, OutputNormal) + v.AutoRenderHyperLinks = true + + v.writeString("htt") + // No hyperlinks are generated for incomplete URLs + assert.Equal(t, "", v.lines[0][0].hyperlink) + // Writing more characters to the same line makes the link complete (even + // though we didn't see a newline yet) + v.writeString("ps://example.com") + assert.Equal(t, "https://example.com", v.lines[0][0].hyperlink) + + v.Clear() + // Valid but incomplete URL + v.writeString("https://exa") + assert.Equal(t, "https://exa", v.lines[0][0].hyperlink) + // Writing more characters to the same fixes the link + v.writeString("mple.com") + assert.Equal(t, "https://example.com", v.lines[0][0].hyperlink) +} + +func TestContainsColoredText(t *testing.T) { + hexColor := func(text string, hexStr string) []cell { + cells := make([]cell, len(text)) + hex := GetColor(hexStr) + for i, chr := range text { + cells[i] = cell{fgColor: hex, chr: string(chr)} + } + return cells + } + red := "#ff0000" + green := "#00ff00" + redStr := func(text string) []cell { return hexColor(text, red) } + greenStr := func(text string) []cell { return hexColor(text, green) } + + concat := func(lines ...[]cell) []cell { + var cells []cell + for _, line := range lines { + cells = append(cells, line...) + } + return cells + } + + tests := []struct { + lines [][]cell + fgColorStr string + text string + expected bool + }{ + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: red, + text: "a", + expected: true, + }, + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: red, + text: "b", + expected: false, + }, + { + lines: [][]cell{concat(redStr("a"))}, + fgColorStr: green, + text: "b", + expected: false, + }, + { + lines: [][]cell{concat(redStr("hel"), greenStr("lo"), redStr(" World!"))}, + fgColorStr: red, + text: "hello", + expected: false, + }, + { + lines: [][]cell{concat(redStr("hel"), greenStr("lo"), redStr(" World!"))}, + fgColorStr: green, + text: "lo", + expected: true, + }, + { + lines: [][]cell{ + redStr("hel"), + redStr("lo"), + }, + fgColorStr: red, + text: "hello", + expected: false, + }, + } + + for i, test := range tests { + v := &View{lines: test.lines} + assert.Equal(t, test.expected, v.ContainsColoredText(test.fgColorStr, test.text), "Test %d failed", i) + } +} + +func stringToCells(s string) []cell { + var cells []cell + state := -1 + for len(s) > 0 { + var c string + var w int + c, s, w, state = uniseg.FirstGraphemeClusterInString(s, state) + cells = append(cells, cell{chr: c, width: w}) + } + return cells +} + +func cellsToString(cells []cell) string { + var s strings.Builder + for _, c := range cells { + s.WriteString(c.chr) + } + return s.String() +} + +func cellsToStrings(cells []cell) []string { + s := []string{} + for _, c := range cells { + s = append(s, c.chr) + } + return s +} + +func TestLineWrap(t *testing.T) { + testCases := []struct { + name string + line string + columns int + expected []string + }{ + { + name: "Wrap on space", + line: "Hello World", + columns: 5, + expected: []string{ + "Hello", + "World", + }, + }, + { + name: "Wrap on hyphen", + line: "Hello-World", + columns: 6, + expected: []string{ + "Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 2", + line: "Blah Hello-World", + columns: 12, + expected: []string{ + "Blah Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 3", + line: "Blah Hello-World", + columns: 11, + expected: []string{ + "Blah Hello-", + "World", + }, + }, + { + name: "Wrap on hyphen 4", + line: "Blah Hello-World", + columns: 10, + expected: []string{ + "Blah Hello", + "-World", + }, + }, + { + name: "Wrap on space 2", + line: "Blah Hello World", + columns: 10, + expected: []string{ + "Blah Hello", + "World", + }, + }, + { + name: "Wrap on space with more words", + line: "Longer word here", + columns: 10, + expected: []string{ + "Longer", + "word here", + }, + }, + { + name: "Split word that's too long", + line: "ThisWordIsWayTooLong", + columns: 10, + expected: []string{ + "ThisWordIs", + "WayTooLong", + }, + }, + { + name: "Split word that's too long over multiple lines", + line: "ThisWordIsWayTooLong", + columns: 5, + expected: []string{ + "ThisW", + "ordIs", + "WayTo", + "oLong", + }, + }, + { + name: "Lots of hyphens", + line: "one-two-three-four-five", + columns: 8, + expected: []string{ + "one-two-", + "three-", + "four-", + "five", + }, + }, + { + name: "Several lines using all the available width", + line: "aaa bb cc ddd-ee ff", + columns: 5, + expected: []string{ + "aaa", + "bb cc", + "ddd-", + "ee ff", + }, + }, + { + name: "Multi-cell runes", + line: "🐤🐤🐤 🐝🐝 🙉 🦊🦊🦊-🐬🐬 🦢🦢", + columns: 9, + expected: []string{ + "🐤🐤🐤", + "🐝🐝 🙉", + "🦊🦊🦊-", + "🐬🐬 🦢🦢", + }, + }, + { + name: "Space in last column", + line: "hello world", + columns: 6, + expected: []string{ + "hello", + "world", + }, + }, + { + name: "Hyphen in last column", + line: "hello-world", + columns: 6, + expected: []string{ + "hello-", + "world", + }, + }, + { + name: "English text", + line: "+The sea reach of the Thames stretched before us like the bedinnind of an interminable waterway. In the offind the sea and the sky were welded todether without a joint, and in the luminous space the tanned sails of the bardes drifting blah blah", + columns: 81, + expected: []string{ + "+The sea reach of the Thames stretched before us like the bedinnind of an", + "interminable waterway. In the offind the sea and the sky were welded todether", + "without a joint, and in the luminous space the tanned sails of the bardes", + "drifting blah blah", + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + lineCells := stringToCells(tc.line) + + result := lineWrap(lineCells, tc.columns) + + resultStrings := make([]string, len(result)) + for i, line := range result { + resultStrings[i] = cellsToString(line) + } + + assert.EqualValues(t, tc.expected, resultStrings) + }) + } +} diff --git a/pkg/gui/background.go b/pkg/gui/background.go index 11f0dde5b..cedc6a78c 100644 --- a/pkg/gui/background.go +++ b/pkg/gui/background.go @@ -5,7 +5,7 @@ import ( "runtime" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index 6c86f374e..7584b5a12 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index 55415c761..056035cce 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/context/main_context.go b/pkg/gui/context/main_context.go index f749c4be2..c8b6edade 100644 --- a/pkg/gui/context/main_context.go +++ b/pkg/gui/context/main_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go index 167bdb41f..334c2e374 100644 --- a/pkg/gui/context/patch_explorer_context.go +++ b/pkg/gui/context/patch_explorer_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/patch_exploring" "github.com/jesseduffield/lazygit/pkg/gui/types" deadlock "github.com/sasha-s/go-deadlock" diff --git a/pkg/gui/context/simple_context.go b/pkg/gui/context/simple_context.go index 6405e91f5..83d201f3a 100644 --- a/pkg/gui/context/simple_context.go +++ b/pkg/gui/context/simple_context.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index 55a06f286..fee5492ac 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -4,9 +4,9 @@ import ( "fmt" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/context/view_trait.go b/pkg/gui/context/view_trait.go index d3825b9cf..8e12e083f 100644 --- a/pkg/gui/context/view_trait.go +++ b/pkg/gui/context/view_trait.go @@ -1,7 +1,7 @@ package context import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 51c4c3bab..51e240a5d 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -1,8 +1,8 @@ package gui import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands" diff --git a/pkg/gui/controllers/base_controller.go b/pkg/gui/controllers/base_controller.go index 4ea0b1fd3..f91f0b4cc 100644 --- a/pkg/gui/controllers/base_controller.go +++ b/pkg/gui/controllers/base_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index ab3b3c8d0..2011bb970 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/gookit/color" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/presentation" diff --git a/pkg/gui/controllers/commit_description_controller.go b/pkg/gui/controllers/commit_description_controller.go index 8ffcb4f58..4b799a6a0 100644 --- a/pkg/gui/controllers/commit_description_controller.go +++ b/pkg/gui/controllers/commit_description_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/commit_message_controller.go b/pkg/gui/controllers/commit_message_controller.go index b92e8dd4c..53c7e761e 100644 --- a/pkg/gui/controllers/commit_message_controller.go +++ b/pkg/gui/controllers/commit_message_controller.go @@ -3,8 +3,8 @@ package controllers import ( "errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 699360b63..0640b7f32 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -6,11 +6,11 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/filetree" diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index fa39cf374..6d9074802 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index ee856ddb5..234a2b65c 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index 1ae560685..079ad24b5 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/app_status_helper.go b/pkg/gui/controllers/helpers/app_status_helper.go index 587d219d3..89de221b8 100644 --- a/pkg/gui/controllers/helpers/app_status_helper.go +++ b/pkg/gui/controllers/helpers/app_status_helper.go @@ -3,7 +3,7 @@ package helpers import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/status" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index 9748fecc5..c3f4242bf 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index 73f1d9baf..55b759b48 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/helpers/gpg_helper.go b/pkg/gui/controllers/helpers/gpg_helper.go index afac52f13..30ec6ceef 100644 --- a/pkg/gui/controllers/helpers/gpg_helper.go +++ b/pkg/gui/controllers/helpers/gpg_helper.go @@ -3,9 +3,9 @@ package helpers import ( "fmt" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/helpers/inline_status_helper.go b/pkg/gui/controllers/helpers/inline_status_helper.go index 38a4e2cf7..13c112811 100644 --- a/pkg/gui/controllers/helpers/inline_status_helper.go +++ b/pkg/gui/controllers/helpers/inline_status_helper.go @@ -3,7 +3,7 @@ package helpers import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 7f51bc35d..8b8d1fb7c 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -7,9 +7,9 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index f2d5a9a49..4a61bde18 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -7,10 +7,10 @@ import ( "time" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts" diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 791f0d481..c10fad81d 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -5,9 +5,9 @@ import ( "strings" "text/template" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index 158606b01..156c0ab30 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -8,11 +8,11 @@ import ( "strings" "sync" - "github.com/jesseduffield/gocui" appTypes "github.com/jesseduffield/lazygit/pkg/app/types" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/env" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 9b3dcec64..8307a7f67 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/helpers/suggestions_helper.go b/pkg/gui/controllers/helpers/suggestions_helper.go index de0d04843..e88fe3822 100644 --- a/pkg/gui/controllers/helpers/suggestions_helper.go +++ b/pkg/gui/controllers/helpers/suggestions_helper.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/update_helper.go b/pkg/gui/controllers/helpers/update_helper.go index 4491b4330..a108b0bf4 100644 --- a/pkg/gui/controllers/helpers/update_helper.go +++ b/pkg/gui/controllers/helpers/update_helper.go @@ -3,7 +3,7 @@ package helpers import ( "errors" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/updates" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/helpers/window_helper.go b/pkg/gui/controllers/helpers/window_helper.go index e2b0e38f0..53531c2ff 100644 --- a/pkg/gui/controllers/helpers/window_helper.go +++ b/pkg/gui/controllers/helpers/window_helper.go @@ -3,7 +3,7 @@ package helpers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" diff --git a/pkg/gui/controllers/helpers/worktree_helper.go b/pkg/gui/controllers/helpers/worktree_helper.go index 671743fe6..6cb22084b 100644 --- a/pkg/gui/controllers/helpers/worktree_helper.go +++ b/pkg/gui/controllers/helpers/worktree_helper.go @@ -4,9 +4,9 @@ import ( "errors" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index c0ef2faec..25eb2c137 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -3,7 +3,7 @@ package controllers import ( "log" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index a56860bab..dba08552c 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index e4f88b3ca..23f772794 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -4,9 +4,9 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/context/traits" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index fa7e6438a..58d88485a 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index dc358bb03..1de192928 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -3,7 +3,7 @@ package controllers import ( "os" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index 4d418d7df..9afba75b1 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index fdaafec5d..9c0ef078f 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -3,7 +3,7 @@ package controllers import ( "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/controllers/prompt_controller.go b/pkg/gui/controllers/prompt_controller.go index 1f6953951..1ad19fa97 100644 --- a/pkg/gui/controllers/prompt_controller.go +++ b/pkg/gui/controllers/prompt_controller.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 4713a6e23..40ad6f7e3 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index 8d47d1721..cbba7b656 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -7,8 +7,8 @@ import ( "slices" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/screen_mode_actions.go b/pkg/gui/controllers/screen_mode_actions.go index a09331065..887f34603 100644 --- a/pkg/gui/controllers/screen_mode_actions.go +++ b/pkg/gui/controllers/screen_mode_actions.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/search_prompt_controller.go b/pkg/gui/controllers/search_prompt_controller.go index 9eca74c90..6e0d0b824 100644 --- a/pkg/gui/controllers/search_prompt_controller.go +++ b/pkg/gui/controllers/search_prompt_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/side_window_controller.go b/pkg/gui/controllers/side_window_controller.go index 2cd421e0e..ddf0f97bd 100644 --- a/pkg/gui/controllers/side_window_controller.go +++ b/pkg/gui/controllers/side_window_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index f667dd212..dbce8cff4 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go index 377fd4994..a3e08e384 100644 --- a/pkg/gui/controllers/status_controller.go +++ b/pkg/gui/controllers/status_controller.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index c425453aa..d8b403975 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -5,8 +5,8 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 715ee12e9..e5de7619b 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/switch_to_focused_main_view_controller.go b/pkg/gui/controllers/switch_to_focused_main_view_controller.go index 132ec96db..5161a5c83 100644 --- a/pkg/gui/controllers/switch_to_focused_main_view_controller.go +++ b/pkg/gui/controllers/switch_to_focused_main_view_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 023ac0d25..00178b1bb 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index c8a02df87..22c208a38 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index cdc8a1280..02e27ddce 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/gui/controllers/vertical_scroll_controller.go b/pkg/gui/controllers/vertical_scroll_controller.go index b88574451..1db9bb76e 100644 --- a/pkg/gui/controllers/vertical_scroll_controller.go +++ b/pkg/gui/controllers/vertical_scroll_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/view_selection_controller.go b/pkg/gui/controllers/view_selection_controller.go index 638c46ba6..0d69c5109 100644 --- a/pkg/gui/controllers/view_selection_controller.go +++ b/pkg/gui/controllers/view_selection_controller.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 82357922f..c19d12377 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -8,7 +8,7 @@ import ( "math/rand" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 157f06495..3f6d7154a 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func (gui *Gui) handleEditorKeypress(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier, allowMultiline bool) bool { diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 9b6551d33..3c4896af4 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1da39ce05..8822c27a8 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -14,7 +14,6 @@ import ( "sync" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazycore/pkg/boxlayout" appTypes "github.com/jesseduffield/lazygit/pkg/app/types" "github.com/jesseduffield/lazygit/pkg/commands" @@ -24,6 +23,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index d946659d1..13f49c46b 100644 --- a/pkg/gui/gui_common.go +++ b/pkg/gui/gui_common.go @@ -1,10 +1,10 @@ package gui import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/tasks" diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index 35c201a14..8f3f64dbb 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -7,9 +7,9 @@ import ( "time" "github.com/gdamore/tcell/v2" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 9f92fbae8..6ca06a0fc 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -4,7 +4,7 @@ import ( "errors" "log" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/keybindings/keybindings.go b/pkg/gui/keybindings/keybindings.go index 76b757b72..4ffee81b4 100644 --- a/pkg/gui/keybindings/keybindings.go +++ b/pkg/gui/keybindings/keybindings.go @@ -6,9 +6,9 @@ import ( "strings" "unicode/utf8" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/constants" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 7ab7a88a0..21d83ca04 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -3,7 +3,7 @@ package gui import ( "errors" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 30055e805..82f4fcac0 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index aab024ec4..5f1a29e61 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go index d8824016f..ab067410d 100644 --- a/pkg/gui/popup/popup_handler.go +++ b/pkg/gui/popup/popup_handler.go @@ -5,8 +5,8 @@ import ( "errors" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/common" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/gui/pty.go b/pkg/gui/pty.go index 66bb355f2..f6356b9c0 100644 --- a/pkg/gui/pty.go +++ b/pkg/gui/pty.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/creack/pty" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) diff --git a/pkg/gui/pty_windows.go b/pkg/gui/pty_windows.go index 39577a199..31d763870 100644 --- a/pkg/gui/pty_windows.go +++ b/pkg/gui/pty_windows.go @@ -4,7 +4,7 @@ import ( "fmt" "os/exec" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) func (gui *Gui) onResize() error { diff --git a/pkg/gui/services/custom_commands/client.go b/pkg/gui/services/custom_commands/client.go index 12d8c7862..aceaef2dd 100644 --- a/pkg/gui/services/custom_commands/client.go +++ b/pkg/gui/services/custom_commands/client.go @@ -1,8 +1,8 @@ package custom_commands import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index a6634c07b..816435588 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -6,8 +6,8 @@ import ( "strings" "text/template" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/style" diff --git a/pkg/gui/services/custom_commands/keybinding_creator.go b/pkg/gui/services/custom_commands/keybinding_creator.go index 259954c17..d7acbcacc 100644 --- a/pkg/gui/services/custom_commands/keybinding_creator.go +++ b/pkg/gui/services/custom_commands/keybinding_creator.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" diff --git a/pkg/gui/status/status_manager.go b/pkg/gui/status/status_manager.go index 40c68fe2d..2f822c1ee 100644 --- a/pkg/gui/status/status_manager.go +++ b/pkg/gui/status/status_manager.go @@ -3,8 +3,8 @@ package status import ( "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" diff --git a/pkg/gui/tasks_adapter.go b/pkg/gui/tasks_adapter.go index 151d1566b..3bfc64100 100644 --- a/pkg/gui/tasks_adapter.go +++ b/pkg/gui/tasks_adapter.go @@ -5,7 +5,7 @@ import ( "os/exec" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/tasks" ) diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index ef81e11cb..2ba381078 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -5,7 +5,7 @@ import ( "os" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/popup" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/integration/components" diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 06c459add..1b06baa16 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -1,13 +1,13 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/tasks" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 5ef632196..4f1b90c64 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -1,8 +1,8 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/patch_exploring" "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/types/keybindings.go b/pkg/gui/types/keybindings.go index 9289dbe9a..aa3a95e7e 100644 --- a/pkg/gui/types/keybindings.go +++ b/pkg/gui/types/keybindings.go @@ -1,7 +1,7 @@ package types import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" ) diff --git a/pkg/gui/types/views.go b/pkg/gui/types/views.go index 46a67d23a..c740ccb2e 100644 --- a/pkg/gui/types/views.go +++ b/pkg/gui/types/views.go @@ -1,6 +1,6 @@ package types -import "github.com/jesseduffield/gocui" +import "github.com/jesseduffield/lazygit/pkg/gocui" type Views struct { Status *gocui.View diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index b8ea49c44..453ccd6c9 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -3,7 +3,7 @@ package gui import ( "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/tasks" diff --git a/pkg/gui/views.go b/pkg/gui/views.go index ba4b4373f..093257998 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/samber/lo" diff --git a/pkg/integration/clients/tui.go b/pkg/integration/clients/tui.go index 13b03726e..0f7a2b3fe 100644 --- a/pkg/integration/clients/tui.go +++ b/pkg/integration/clients/tui.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazycore/pkg/utils" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/integration/components" diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index ea1c79124..ab32f9f89 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -3,10 +3,10 @@ package components import ( "testing" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/stretchr/testify/assert" diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index ea005d371..ee7c5b68a 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/samber/lo" ) diff --git a/pkg/integration/components/views.go b/pkg/integration/components/views.go index 1d32f4828..90795d942 100644 --- a/pkg/integration/components/views.go +++ b/pkg/integration/components/views.go @@ -3,7 +3,7 @@ package components import ( "fmt" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) type Views struct { diff --git a/pkg/integration/types/types.go b/pkg/integration/types/types.go index 9c4f057d2..752639058 100644 --- a/pkg/integration/types/types.go +++ b/pkg/integration/types/types.go @@ -1,9 +1,9 @@ package types import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) diff --git a/pkg/tasks/async_handler.go b/pkg/tasks/async_handler.go index 658687af9..ab0770568 100644 --- a/pkg/tasks/async_handler.go +++ b/pkg/tasks/async_handler.go @@ -1,7 +1,7 @@ package tasks import ( - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/sasha-s/go-deadlock" ) diff --git a/pkg/tasks/async_handler_test.go b/pkg/tasks/async_handler_test.go index 6da363cd9..6b354d9c5 100644 --- a/pkg/tasks/async_handler_test.go +++ b/pkg/tasks/async_handler_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 5c5875fa8..74c639b24 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sasha-s/go-deadlock" "github.com/sirupsen/logrus" diff --git a/pkg/tasks/tasks_test.go b/pkg/tasks/tasks_test.go index 452b91eaf..40ff0033d 100644 --- a/pkg/tasks/tasks_test.go +++ b/pkg/tasks/tasks_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/theme/gocui.go b/pkg/theme/gocui.go index 5f8e6a611..6d10f8666 100644 --- a/pkg/theme/gocui.go +++ b/pkg/theme/gocui.go @@ -2,7 +2,7 @@ package theme import ( "github.com/gookit/color" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go index acd8ebf71..d2e5b1291 100644 --- a/pkg/theme/theme.go +++ b/pkg/theme/theme.go @@ -1,8 +1,8 @@ package theme import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/style" ) diff --git a/pkg/utils/lines_test.go b/pkg/utils/lines_test.go index 973310a33..2b97761d3 100644 --- a/pkg/utils/lines_test.go +++ b/pkg/utils/lines_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/stretchr/testify/assert" ) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7eb24b736..40411d520 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gocui" ) // GetProjectRoot returns the path to the root of the project. Only to be used diff --git a/vendor/github.com/jesseduffield/gocui/.gitignore b/vendor/github.com/jesseduffield/gocui/.gitignore deleted file mode 100644 index 1377554eb..000000000 --- a/vendor/github.com/jesseduffield/gocui/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swp diff --git a/vendor/modules.txt b/vendor/modules.txt index 942160eb2..73ad86ab5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -99,9 +99,6 @@ github.com/integrii/flaggy github.com/jesseduffield/generics/maps github.com/jesseduffield/generics/orderedset github.com/jesseduffield/generics/set -# github.com/jesseduffield/gocui v0.3.1-0.20260327132312-944dab3bc980 -## explicit; go 1.25 -github.com/jesseduffield/gocui # github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 ## explicit; go 1.18 github.com/jesseduffield/lazycore/pkg/boxlayout