diff --git a/docs-master/Config.md b/docs-master/Config.md index fa6b3eeacc7..b7208f719fd 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -110,6 +110,10 @@ gui: # is true. expandedSidePanelWeight: 2 + # If true, the expanded side panel will only expand as much as its content + # requires. Only relevant if `expandFocusedSidePanel` is true. + expandedFocusedSidePanelFitsContent: false + # Sometimes the main window is split in two (e.g. when the selected file has # both staged and unstaged changes). This setting controls how the two sections # are split. diff --git a/pkg/app/entry_point.go b/pkg/app/entry_point.go index 8b1a2a040eb..17667f809ce 100644 --- a/pkg/app/entry_point.go +++ b/pkg/app/entry_point.go @@ -262,7 +262,8 @@ func parseGitArg(gitArg string) appTypes.GitArg { string(appTypes.GitArgStash), } - log.Fatalf("Invalid git arg value: '%s'. Must be one of the following values: %s. e.g. 'lazygit status'. See 'lazygit --help'.", + log.Fatalf( + "Invalid git arg value: '%s'. Must be one of the following values: %s. e.g. 'lazygit status'. See 'lazygit --help'.", gitArg, strings.Join(permittedValues, ", "), ) diff --git a/pkg/commands/git_commands/branch_loader_test.go b/pkg/commands/git_commands/branch_loader_test.go index f20ce6186e0..e40d9d89986 100644 --- a/pkg/commands/git_commands/branch_loader_test.go +++ b/pkg/commands/git_commands/branch_loader_test.go @@ -442,7 +442,8 @@ func TestGetBehindBaseBranchValuesForAllBranches_FastPath_ClearsStaleValueWhenBr } err := loader.GetBehindBaseBranchValuesForAllBranches( - []*models.Branch{feat, ghost}, mainBranches, func() {}) + []*models.Branch{feat, ghost}, mainBranches, func() {}, + ) assert.NoError(t, err) assert.Equal(t, int32(5), feat.BehindBaseBranch.Load(), "feat-x should be updated to fresh value") diff --git a/pkg/commands/git_commands/branch_test.go b/pkg/commands/git_commands/branch_test.go index a0c0096b945..dc07273da14 100644 --- a/pkg/commands/git_commands/branch_test.go +++ b/pkg/commands/git_commands/branch_test.go @@ -287,7 +287,8 @@ func TestBranchCurrentBranchInfo(t *testing.T) { []string{"branch", "--points-at=HEAD", "--format=%(HEAD)%00%(objectname)%00%(refname)"}, "*\x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00(头指针在 679b0456 分离)\n"+ " \x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00refs/heads/master\n", - nil), + nil, + ), func(info BranchInfo, err error) { assert.NoError(t, err) assert.EqualValues(t, "679b0456f3db7c505b398def84e7d023e5b55a8d", info.RefName) diff --git a/pkg/commands/git_commands/file_loader_test.go b/pkg/commands/git_commands/file_loader_test.go index ec1f502f1a8..c478d645bd7 100644 --- a/pkg/commands/git_commands/file_loader_test.go +++ b/pkg/commands/git_commands/file_loader_test.go @@ -30,11 +30,13 @@ func TestFileGetStatusFiles(t *testing.T) { testName: "Several files found", similarityThreshold: 50, runner: oscommands.NewFakeRunner(t). - ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, + ExpectGitArgs( + []string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, "MM file1.txt\x00A file3.txt\x00AM file2.txt\x00?? file4.txt\x00UU file5.txt", nil, ). - ExpectGitArgs([]string{"diff", "--numstat", "-z", "HEAD"}, + ExpectGitArgs( + []string{"diff", "--numstat", "-z", "HEAD"}, "4\t1\tfile1.txt\x001\t0\tfile2.txt\x002\t2\tfile3.txt\x000\t2\tfile4.txt\x002\t2\tfile5.txt", nil, ), @@ -136,7 +138,8 @@ func TestFileGetStatusFiles(t *testing.T) { testName: "Renamed files", similarityThreshold: 50, runner: oscommands.NewFakeRunner(t). - ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, + ExpectGitArgs( + []string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, "R after1.txt\x00before1.txt\x00RM after2.txt\x00before2.txt", nil, ), @@ -173,7 +176,8 @@ func TestFileGetStatusFiles(t *testing.T) { testName: "File with arrow in name", similarityThreshold: 50, runner: oscommands.NewFakeRunner(t). - ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, + ExpectGitArgs( + []string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, `?? a -> b.txt`, nil, ), @@ -196,7 +200,8 @@ func TestFileGetStatusFiles(t *testing.T) { testName: "Copied files", similarityThreshold: 50, runner: oscommands.NewFakeRunner(t). - ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, + ExpectGitArgs( + []string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, "C copy1.txt\x00original.txt\x00CM copy2.txt\x00original.txt", nil, ), diff --git a/pkg/commands/git_commands/flow_test.go b/pkg/commands/git_commands/flow_test.go index 2dab0a43e31..7d68952f4bb 100644 --- a/pkg/commands/git_commands/flow_test.go +++ b/pkg/commands/git_commands/flow_test.go @@ -65,7 +65,8 @@ func TestStartCmdObj(t *testing.T) { t.Run(s.testName, func(t *testing.T) { instance := buildFlowCommands(commonDeps{}) - assert.Equal(t, + assert.Equal( + t, instance.StartCmdObj(s.branchType, s.branchName).Args(), s.expected, ) diff --git a/pkg/commands/git_commands/repo_paths_test.go b/pkg/commands/git_commands/repo_paths_test.go index 29c40acee90..d1552e03baf 100644 --- a/pkg/commands/git_commands/repo_paths_test.go +++ b/pkg/commands/git_commands/repo_paths_test.go @@ -55,7 +55,8 @@ func TestGetRepoPaths(t *testing.T) { runner.ExpectGitArgs( append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"), strings.Join(mockOutput, "\n"), - nil) + nil, + ) }, Path: "/path/to/repo", Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{ @@ -103,7 +104,8 @@ func TestGetRepoPaths(t *testing.T) { runner.ExpectGitArgs( append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"), strings.Join(mockOutput, "\n"), - nil) + nil, + ) }, Path: "/path/to/repo", Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{ @@ -152,7 +154,8 @@ func TestGetRepoPaths(t *testing.T) { runner.ExpectGitArgs( append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"), strings.Join(mockOutput, "\n"), - nil) + nil, + ) }, Path: "/path/to/repo/submodule1", Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{ @@ -178,7 +181,8 @@ func TestGetRepoPaths(t *testing.T) { runner.ExpectGitArgs( append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"), "", - errors.New("fatal: invalid gitfile format: /path/to/repo/worktree2/.git")) + errors.New("fatal: invalid gitfile format: /path/to/repo/worktree2/.git"), + ) }, Path: "/path/to/repo/worktree2", Expected: nil, diff --git a/pkg/commands/git_commands/stash_loader_test.go b/pkg/commands/git_commands/stash_loader_test.go index 7ed000589d4..af8cb87384f 100644 --- a/pkg/commands/git_commands/stash_loader_test.go +++ b/pkg/commands/git_commands/stash_loader_test.go @@ -35,7 +35,8 @@ func TestGetStashEntries(t *testing.T) { "", oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%ct|%gs"}, - fmt.Sprintf("fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00deadbeef|%d|WIP on master: bb86a3f update github template\x00", + fmt.Sprintf( + "fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00deadbeef|%d|WIP on master: bb86a3f update github template\x00", hoursAgo, daysAgo, ), nil), diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go index 328da140462..63f6718e56b 100644 --- a/pkg/commands/git_commands/working_tree.go +++ b/pkg/commands/git_commands/working_tree.go @@ -296,7 +296,8 @@ func (self *WorkingTreeCommands) removeEmptyDirs(removedFilePaths []string, sele lo.FilterMap(removedFilePaths, func(filePath string, _ int) (string, bool) { dir := path.Dir(filePath) return dir, dir != "." && isUnderSelectedDir(dir, selectedDirs) - })) + }), + ) for { var removed []string diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index e7267158a6f..5f95c6cadd2 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -449,7 +449,8 @@ func migrateAllBranchesLogCmd(rootNode *yaml.Node, changes *ChangesSet) error { // We will later populate it with the individual allBranchesLogCmd record cmdsKeyNode = &yaml.Node{Kind: yaml.ScalarNode, Value: "allBranchesLogCmds"} cmdsValueNode = &yaml.Node{Kind: yaml.SequenceNode, Content: []*yaml.Node{}} - gitNode.Content = append(gitNode.Content, + gitNode.Content = append( + gitNode.Content, cmdsKeyNode, cmdsValueNode, ) diff --git a/pkg/config/editor_presets.go b/pkg/config/editor_presets.go index 5fcde97c54a..c101236ee2c 100644 --- a/pkg/config/editor_presets.go +++ b/pkg/config/editor_presets.go @@ -50,13 +50,13 @@ type editPreset struct { suspend func() bool } -func returnBool(a bool) func() bool { return (func() bool { return a }) } +func returnBool(a bool) func() bool { return func() bool { return a } } // IF YOU ADD A PRESET TO THIS FUNCTION YOU MUST UPDATE THE `Supported presets` SECTION OF docs/Config.md func getPreset(shell string, osConfig *OSConfig, guessDefaultEditor func() string) *editPreset { var nvimRemoteEditTemplate, nvimRemoteEditAtLineTemplate, nvimRemoteOpenDirInEditorTemplate string // By default fish doesn't have SHELL variable set, but it does have FISH_VERSION since Nov 2012. - if (strings.HasSuffix(shell, "fish")) || (os.Getenv("FISH_VERSION") != "") { + if strings.HasSuffix(shell, "fish") || (os.Getenv("FISH_VERSION") != "") { nvimRemoteEditTemplate = `begin; if test -z "$NVIM"; nvim -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; end; end` nvimRemoteEditAtLineTemplate = `begin; if test -z "$NVIM"; nvim +{{line}} -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; nvim --server "$NVIM" --remote-send ":{{line}}"; end; end` nvimRemoteOpenDirInEditorTemplate = `begin; if test -z "$NVIM"; nvim -- {{dir}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{dir}}; end; end` diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index d1f760ed1d0..aab86d594e2 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -102,6 +102,8 @@ type GuiConfig struct { ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"` // The weight of the expanded side panel, relative to the other panels. 2 means twice as tall as the other panels. Only relevant if `expandFocusedSidePanel` is true. ExpandedSidePanelWeight int `yaml:"expandedSidePanelWeight"` + // If true, the expanded side panel will only expand as much as its content requires. Only relevant if `expandFocusedSidePanel` is true. + ExpandedFocusedSidePanelFitsContent bool `yaml:"expandedFocusedSidePanelFitsContent"` // Sometimes the main window is split in two (e.g. when the selected file has both staged and unstaged changes). This setting controls how the two sections are split. // Options are: // - 'horizontal': split the window horizontally @@ -827,25 +829,26 @@ func GetDefaultConfig() *UserConfig { func GetDefaultConfigForPlatform(platform string) *UserConfig { return &UserConfig{ Gui: GuiConfig{ - ScrollHeight: 2, - ScrollPastBottom: true, - ScrollOffMargin: 2, - ScrollOffBehavior: "margin", - TabWidth: 4, - MouseEvents: true, - SkipAmendWarning: false, - SkipDiscardChangeWarning: false, - SkipStashWarning: false, - SidePanelWidth: 0.3333, - ExpandFocusedSidePanel: false, - ExpandedSidePanelWeight: 2, - MainPanelSplitMode: "flexible", - EnlargedSideViewLocation: "left", - WrapLinesInStagingView: true, - UseHunkModeInStagingView: true, - Language: "auto", - TimeFormat: "02 Jan 06", - ShortTimeFormat: time.Kitchen, + ScrollHeight: 2, + ScrollPastBottom: true, + ScrollOffMargin: 2, + ScrollOffBehavior: "margin", + TabWidth: 4, + MouseEvents: true, + SkipAmendWarning: false, + SkipDiscardChangeWarning: false, + SkipStashWarning: false, + SidePanelWidth: 0.3333, + ExpandFocusedSidePanel: false, + ExpandedSidePanelWeight: 2, + ExpandedFocusedSidePanelFitsContent: false, + MainPanelSplitMode: "flexible", + EnlargedSideViewLocation: "left", + WrapLinesInStagingView: true, + UseHunkModeInStagingView: true, + Language: "auto", + TimeFormat: "02 Jan 06", + ShortTimeFormat: time.Kitchen, Theme: ThemeConfig{ ActiveBorderColor: []string{"green", "bold"}, SearchingActiveBorderColor: []string{"cyan", "bold"}, diff --git a/pkg/config/user_config_validation.go b/pkg/config/user_config_validation.go index 109b3f1d038..7db1559844b 100644 --- a/pkg/config/user_config_validation.go +++ b/pkg/config/user_config_validation.go @@ -124,7 +124,8 @@ func validateKeybindingsRecurse(path string, node any) error { } else if value.Kind() == reflect.Slice { for i := range value.Len() { if err := validateKeybindingsRecurse( - fmt.Sprintf("%s[%d]", path, i), value.Index(i).Interface()); err != nil { + fmt.Sprintf("%s[%d]", path, i), value.Index(i).Interface(), + ); err != nil { return err } } diff --git a/pkg/gocui/tcell_driver.go b/pkg/gocui/tcell_driver.go index b2fd40c19a9..a1f72a37b11 100644 --- a/pkg/gocui/tcell_driver.go +++ b/pkg/gocui/tcell_driver.go @@ -272,11 +272,11 @@ func (g *Gui) pollEvent() GocuiEvent { if g.playRecording { select { case ev := <-g.ReplayedEvents.Keys: - tev = (ev).toTcellEvent() + tev = ev.toTcellEvent() case ev := <-g.ReplayedEvents.Resizes: - tev = (ev).toTcellEvent() + tev = ev.toTcellEvent() case ev := <-g.ReplayedEvents.MouseEvents: - tev = (ev).toTcellEvent() + tev = ev.toTcellEvent() } } else { tev = <-Screen.EventQ() diff --git a/pkg/gui/background.go b/pkg/gui/background.go index 8795b49aac1..73354f32338 100644 --- a/pkg/gui/background.go +++ b/pkg/gui/background.go @@ -36,7 +36,8 @@ func (self *BackgroundRoutineMgr) startBackgroundRoutines() { } else { self.gui.c.Log.Errorf( "Value of config option 'refresher.fetchInterval' (%d) is invalid, disabling auto-fetch", - fetchInterval) + fetchInterval, + ) } } @@ -47,7 +48,8 @@ func (self *BackgroundRoutineMgr) startBackgroundRoutines() { } else { self.gui.c.Log.Errorf( "Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh", - refreshInterval) + refreshInterval, + ) } } diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go index 597fc99df29..f232368a875 100644 --- a/pkg/gui/context/list_context_trait.go +++ b/pkg/gui/context/list_context_trait.go @@ -47,7 +47,8 @@ func (self *ListContextTrait) FocusLine(scrollIntoView bool) { oldOrigin, _ := self.GetViewTrait().ViewPortYBounds() self.GetViewTrait().FocusPoint( - self.ModelIndexToViewIndex(self.list.GetSelectedLineIdx()), scrollIntoView) + self.ModelIndexToViewIndex(self.list.GetSelectedLineIdx()), scrollIntoView, + ) if !inOnSearchSelect { self.GetView().SetNearestSearchPosition() } diff --git a/pkg/gui/context/list_renderer.go b/pkg/gui/context/list_renderer.go index e863045e0b4..f17939cdd27 100644 --- a/pkg/gui/context/list_renderer.go +++ b/pkg/gui/context/list_renderer.go @@ -91,7 +91,8 @@ func (self *ListRenderer) renderLines(startIdx int, endIdx int) string { } lines, columnPositions := utils.RenderDisplayStrings( self.getDisplayStrings(startModelIdx, endModelIdx), - columnAlignments) + columnAlignments, + ) self.columnPositions = columnPositions lines = self.insertNonModelItems(nonModelItems, endIdx, startIdx, lines, columnPositions) return strings.Join(lines, "\n") @@ -107,7 +108,8 @@ func (self *ListRenderer) prepareConversionArrays(nonModelItems []*NonModelItem) viewIndicesByModelIndex[i]++ } modelIndicesByViewIndex = slices.Insert( - modelIndicesByViewIndex, item.Index+offset, modelIndicesByViewIndex[item.Index+offset]) + modelIndicesByViewIndex, item.Index+offset, modelIndicesByViewIndex[item.Index+offset], + ) offset++ } self.viewIndicesByModelIndex = viewIndicesByModelIndex diff --git a/pkg/gui/context/list_renderer_test.go b/pkg/gui/context/list_renderer_test.go index 08af680ffd3..c563496c0a7 100644 --- a/pkg/gui/context/list_renderer_test.go +++ b/pkg/gui/context/list_renderer_test.go @@ -138,7 +138,8 @@ func TestListRenderer_renderLines(t *testing.T) { expectedOutput := strings.Join(lo.Map( strings.Split(strings.TrimPrefix(s.expectedOutput, "\n"), "\n"), - func(line string, _ int) string { return strings.TrimSpace(line) }), "\n") + func(line string, _ int) string { return strings.TrimSpace(line) }, + ), "\n") assert.Equal(t, expectedOutput, self.renderLines(s.startIdx, s.endIdx)) }) diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index 056035cce91..be53d8f13e3 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -81,7 +81,8 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext { c.Model().Commits, func(c *models.Commit) bool { return c.Status == models.StatusCherryPickingOrReverting || c.Status == models.StatusConflicted - }) + }, + ) if !found { firstCherryPickOrRevertTodo = 0 } @@ -97,7 +98,8 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext { _, firstRealCommit, found := lo.FindIndexOf( c.Model().Commits, func(c *models.Commit) bool { return !c.IsTODO() - }) + }, + ) if !found { firstRealCommit = 0 } diff --git a/pkg/gui/context/main_context.go b/pkg/gui/context/main_context.go index c8b6edadebb..1461a680924 100644 --- a/pkg/gui/context/main_context.go +++ b/pkg/gui/context/main_context.go @@ -27,7 +27,8 @@ func NewMainContext( Key: key, Focusable: true, HighlightOnFocus: false, - })), + }), + ), SearchTrait: NewSearchTrait(c), } diff --git a/pkg/gui/context/remotes_context.go b/pkg/gui/context/remotes_context.go index 4a96bbc1881..f6cdfb8f5a0 100644 --- a/pkg/gui/context/remotes_context.go +++ b/pkg/gui/context/remotes_context.go @@ -26,7 +26,8 @@ func NewRemotesContext(c *ContextCommon) *RemotesContext { getDisplayStrings := func(_ int, _ int) [][]string { return presentation.GetRemoteListDisplayStrings( - viewModel.GetItems(), c.Modes().Diffing.Ref, c.State().GetItemOperation, c.Tr, c.UserConfig()) + viewModel.GetItems(), c.Modes().Diffing.Ref, c.State().GetItemOperation, c.Tr, c.UserConfig(), + ) } return &RemotesContext{ diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index fee5492ac4b..e3f43d3b793 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -84,7 +84,8 @@ func NewSubCommitsContext( result := []*NonModelItem{} if viewModel.GetRefToShowDivergenceFrom() != "" { _, upstreamIdx, found := lo.FindIndexOf( - c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceRight }) + c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceRight }, + ) if !found { upstreamIdx = 0 } @@ -94,7 +95,8 @@ func NewSubCommitsContext( }) _, localIdx, found := lo.FindIndexOf( - c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft }) + c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft }, + ) if !found { localIdx = len(c.Model().SubCommits) } diff --git a/pkg/gui/context/tags_context.go b/pkg/gui/context/tags_context.go index 0b98b146a49..f0ff673d05b 100644 --- a/pkg/gui/context/tags_context.go +++ b/pkg/gui/context/tags_context.go @@ -30,7 +30,8 @@ func NewTagsContext( return presentation.GetTagListDisplayStrings( viewModel.GetItems(), c.State().GetItemOperation, - c.Modes().Diffing.Ref, c.Tr, c.UserConfig()) + c.Modes().Diffing.Ref, c.Tr, c.UserConfig(), + ) } return &TagsContext{ diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 51e240a5d55..ea3de68aa78 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -42,7 +42,8 @@ func (gui *Gui) resetHelpersAndControllers() { getUnwrappedCommitDescription := func() string { return gui.Views.CommitDescription.TextArea.GetUnwrappedContent() } - commitsHelper := helpers.NewCommitsHelper(helperCommon, + commitsHelper := helpers.NewCommitsHelper( + helperCommon, getCommitSummary, setCommitSummary, getCommitDescription, @@ -284,133 +285,162 @@ func (gui *Gui) resetHelpersAndControllers() { controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context)) } - controllers.AttachControllers(gui.State.Contexts.ReflogCommits, + controllers.AttachControllers( + gui.State.Contexts.ReflogCommits, reflogCommitsController, ) - controllers.AttachControllers(gui.State.Contexts.SubCommits, + controllers.AttachControllers( + gui.State.Contexts.SubCommits, subCommitsController, ) // TODO: add scroll controllers for main panels (need to bring some more functionality across for that e.g. reading more from the currently displayed git command) - controllers.AttachControllers(gui.State.Contexts.Staging, + controllers.AttachControllers( + gui.State.Contexts.Staging, stagingController, patchExplorerControllerFactory.Create(gui.State.Contexts.Staging), verticalScrollControllerFactory.Create(gui.State.Contexts.Staging), ) - controllers.AttachControllers(gui.State.Contexts.StagingSecondary, + controllers.AttachControllers( + gui.State.Contexts.StagingSecondary, stagingSecondaryController, patchExplorerControllerFactory.Create(gui.State.Contexts.StagingSecondary), verticalScrollControllerFactory.Create(gui.State.Contexts.StagingSecondary), ) - controllers.AttachControllers(gui.State.Contexts.CustomPatchBuilder, + controllers.AttachControllers( + gui.State.Contexts.CustomPatchBuilder, patchBuildingController, patchExplorerControllerFactory.Create(gui.State.Contexts.CustomPatchBuilder), verticalScrollControllerFactory.Create(gui.State.Contexts.CustomPatchBuilder), ) - controllers.AttachControllers(gui.State.Contexts.CustomPatchBuilderSecondary, + controllers.AttachControllers( + gui.State.Contexts.CustomPatchBuilderSecondary, verticalScrollControllerFactory.Create(gui.State.Contexts.CustomPatchBuilderSecondary), ) - controllers.AttachControllers(gui.State.Contexts.MergeConflicts, + controllers.AttachControllers( + gui.State.Contexts.MergeConflicts, mergeConflictsController, ) - controllers.AttachControllers(gui.State.Contexts.Normal, + controllers.AttachControllers( + gui.State.Contexts.Normal, mainViewController, verticalScrollControllerFactory.Create(gui.State.Contexts.Normal), viewSelectionControllerFactory.Create(gui.State.Contexts.Normal), ) - controllers.AttachControllers(gui.State.Contexts.NormalSecondary, + controllers.AttachControllers( + gui.State.Contexts.NormalSecondary, secondaryViewController, verticalScrollControllerFactory.Create(gui.State.Contexts.NormalSecondary), viewSelectionControllerFactory.Create(gui.State.Contexts.NormalSecondary), ) - controllers.AttachControllers(gui.State.Contexts.Files, + controllers.AttachControllers( + gui.State.Contexts.Files, filesController, ) - controllers.AttachControllers(gui.State.Contexts.Tags, + controllers.AttachControllers( + gui.State.Contexts.Tags, tagsController, ) - controllers.AttachControllers(gui.State.Contexts.Submodules, + controllers.AttachControllers( + gui.State.Contexts.Submodules, submodulesController, ) - controllers.AttachControllers(gui.State.Contexts.Branches, + controllers.AttachControllers( + gui.State.Contexts.Branches, branchesController, gitFlowController, ) - controllers.AttachControllers(gui.State.Contexts.LocalCommits, + controllers.AttachControllers( + gui.State.Contexts.LocalCommits, localCommitsController, bisectController, ) - controllers.AttachControllers(gui.State.Contexts.CommitFiles, + controllers.AttachControllers( + gui.State.Contexts.CommitFiles, commitFilesController, ) - controllers.AttachControllers(gui.State.Contexts.Remotes, + controllers.AttachControllers( + gui.State.Contexts.Remotes, remotesController, ) - controllers.AttachControllers(gui.State.Contexts.Worktrees, + controllers.AttachControllers( + gui.State.Contexts.Worktrees, worktreesController, ) - controllers.AttachControllers(gui.State.Contexts.Stash, + controllers.AttachControllers( + gui.State.Contexts.Stash, stashController, ) - controllers.AttachControllers(gui.State.Contexts.Menu, + controllers.AttachControllers( + gui.State.Contexts.Menu, menuController, ) - controllers.AttachControllers(gui.State.Contexts.CommitMessage, + controllers.AttachControllers( + gui.State.Contexts.CommitMessage, commitMessageController, ) - controllers.AttachControllers(gui.State.Contexts.CommitDescription, + controllers.AttachControllers( + gui.State.Contexts.CommitDescription, commitDescriptionController, verticalScrollControllerFactory.Create(gui.State.Contexts.CommitDescription), ) - controllers.AttachControllers(gui.State.Contexts.RemoteBranches, + controllers.AttachControllers( + gui.State.Contexts.RemoteBranches, remoteBranchesController, ) - controllers.AttachControllers(gui.State.Contexts.Status, + controllers.AttachControllers( + gui.State.Contexts.Status, statusController, ) - controllers.AttachControllers(gui.State.Contexts.CommandLog, + controllers.AttachControllers( + gui.State.Contexts.CommandLog, commandLogController, ) - controllers.AttachControllers(gui.State.Contexts.Confirmation, + controllers.AttachControllers( + gui.State.Contexts.Confirmation, confirmationController, ) - controllers.AttachControllers(gui.State.Contexts.Prompt, + controllers.AttachControllers( + gui.State.Contexts.Prompt, promptController, ) - controllers.AttachControllers(gui.State.Contexts.Suggestions, + controllers.AttachControllers( + gui.State.Contexts.Suggestions, suggestionsController, ) - controllers.AttachControllers(gui.State.Contexts.Search, + controllers.AttachControllers( + gui.State.Contexts.Search, controllers.NewSearchPromptController(common), ) - controllers.AttachControllers(gui.State.Contexts.Global, + controllers.AttachControllers( + gui.State.Contexts.Global, undoController, globalController, contextLinesController, @@ -419,7 +449,8 @@ func (gui *Gui) resetHelpersAndControllers() { syncController, ) - controllers.AttachControllers(gui.State.Contexts.Snake, + controllers.AttachControllers( + gui.State.Contexts.Snake, snakeController, ) diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 2ddb5055e11..3bc9b24a9a0 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -103,7 +103,8 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ Handler: self.withItem(self.copyRange), GetDisabledReason: self.require(self.itemRangeSelected(self.canCopyCommits)), Description: self.c.Tr.CherryPickCopy, - Tooltip: utils.ResolvePlaceholderString(self.c.Tr.CherryPickCopyTooltip, + Tooltip: utils.ResolvePlaceholderString( + self.c.Tr.CherryPickCopyTooltip, map[string]string{ "paste": opts.Config.Commits.PasteCommits.String(), "escape": opts.Config.Universal.Return.String(), @@ -383,7 +384,8 @@ func (self *BasicCommitsController) openDiffTool(commit *models.Commit) error { Reverse: reverse, IsDirectory: true, Staged: false, - })) + }, + )) return err } diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 24ef84d5406..da65431075e 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -554,30 +554,31 @@ func (self *BranchesController) checkoutPreviousBranch() error { } func (self *BranchesController) checkoutByName() error { - self.c.Prompt(types.PromptOpts{ - Title: self.c.Tr.BranchName + ":", - FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(), - HandleConfirm: func(response string) error { - self.c.LogAction("Checkout branch") - _, branchName, found := self.c.Helpers().Refs.ParseRemoteBranchName(response) - if found { - return self.c.Helpers().Refs.CheckoutRemoteBranch(response, branchName) - } - return self.c.Helpers().Refs.CheckoutRef(response, types.CheckoutRefOptions{ - OnRefNotFound: func(ref string) error { - self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.BranchNotFoundTitle, - Prompt: fmt.Sprintf("%s %s%s", self.c.Tr.BranchNotFoundPrompt, ref, "?"), - HandleConfirm: func() error { - return self.createNewBranchWithName(ref) - }, - }) - - return nil - }, - }) + self.c.Prompt( + types.PromptOpts{ + Title: self.c.Tr.BranchName + ":", + FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(), + HandleConfirm: func(response string) error { + self.c.LogAction("Checkout branch") + _, branchName, found := self.c.Helpers().Refs.ParseRemoteBranchName(response) + if found { + return self.c.Helpers().Refs.CheckoutRemoteBranch(response, branchName) + } + return self.c.Helpers().Refs.CheckoutRef(response, types.CheckoutRefOptions{ + OnRefNotFound: func(ref string) error { + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.BranchNotFoundTitle, + Prompt: fmt.Sprintf("%s %s%s", self.c.Tr.BranchNotFoundPrompt, ref, "?"), + HandleConfirm: func() error { + return self.createNewBranchWithName(ref) + }, + }) + + return nil + }, + }) + }, }, - }, ) return nil @@ -755,7 +756,8 @@ func (self *BranchesController) createSortMenu() error { } return nil }, - self.c.UserConfig().Git.LocalBranchSortOrder) + self.c.UserConfig().Git.LocalBranchSortOrder, + ) } func (self *BranchesController) createResetMenu(selectedBranch *models.Branch) error { @@ -853,7 +855,8 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra } if selectedBranch != checkedOutBranch { - menuItems = append(menuItems, + menuItems = append( + menuItems, &types.MenuItem{ LabelColumns: fromToLabelColumns(checkedOutBranch.Name, selectedBranch.Name), OnPress: func() error { diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index eed9d02b91c..860e60f8f11 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -92,7 +92,8 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] Handler: self.withItems(self.toggleForPatch), GetDisabledReason: self.require(self.itemsSelected()), Description: self.c.Tr.ToggleAddToPatch, - Tooltip: utils.ResolvePlaceholderString(self.c.Tr.ToggleAddToPatchTooltip, + Tooltip: utils.ResolvePlaceholderString( + self.c.Tr.ToggleAddToPatchTooltip, map[string]string{"doc": constants.Links.Docs.CustomPatchDemo}, ), DisplayOnScreen: true, @@ -101,7 +102,8 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] Keys: opts.GetKeys(opts.Config.Files.ToggleStagedAll), Handler: self.withItem(self.toggleAllForPatch), Description: self.c.Tr.ToggleAllInPatch, - Tooltip: utils.ResolvePlaceholderString(self.c.Tr.ToggleAllInPatchTooltip, + Tooltip: utils.ResolvePlaceholderString( + self.c.Tr.ToggleAllInPatchTooltip, map[string]string{"doc": constants.Links.Docs.CustomPatchDemo}, ), }, @@ -294,7 +296,8 @@ func (self *CommitFilesController) openCopyMenu() error { } } return nil - }))(), + }, + ))(), Keys: menuKey('c'), } @@ -429,7 +432,8 @@ func (self *CommitFilesController) openDiffTool(node *filetree.CommitFileNode) e Reverse: reverse, IsDirectory: !node.IsFile(), Staged: false, - })) + }, + )) return err } diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 09f654e2bd9..99d192a49a9 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -940,7 +940,8 @@ func (self *FilesController) handleAmendCommitPress() error { }) } - return self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipAmendWarning, + return self.c.ConfirmIf( + !self.c.UserConfig().Gui.SkipAmendWarning, types.ConfirmOpts{ Title: self.c.Tr.AmendLastCommitTitle, Prompt: self.c.Tr.SureToAmend, @@ -1091,7 +1092,8 @@ func (self *FilesController) openDiffTool(node *filetree.FileNode) error { Reverse: reverse, IsDirectory: !node.IsFile(), Staged: !node.GetHasUnstagedChanges(), - }), + }, + ), ) } diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 079fdedcf53..081935795a5 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -80,7 +80,8 @@ func (self *CherryPickHelper) Paste() error { self.c.Tr.SureCherryPick, map[string]string{ "numCommits": strconv.Itoa(len(self.getData().CherryPickedCommits)), - }), + }, + ), HandleConfirm: func() error { return self.c.WithWaitingStatusSync(self.c.Tr.CherryPickingStatus, func() error { mustStash := IsWorkingTreeDirtyExceptSubmodules(self.c.Model().Files, self.c.Model().Submodules) diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index 3663cd4eac9..d106ec43de5 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -218,7 +218,8 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ Prompt: opts.Prompt, FindSuggestionsFunc: opts.FindSuggestionsFunc, Mask: opts.Mask, - }) + }, + ) context = self.c.Contexts().Prompt @@ -234,7 +235,8 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ types.ConfirmOpts{ Title: opts.Title, Prompt: opts.Prompt, - }) + }, + ) context = self.c.Contexts().Confirmation diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index 668ee916adb..f2597cdfa7b 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -185,7 +185,8 @@ func (self *DiffHelper) OpenDiffToolForRef(selectedRef models.Ref) error { Reverse: reverse, IsDirectory: true, Staged: false, - })) + }, + )) return err } diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index cd141c69770..101b39eafb8 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -281,7 +281,8 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { menuItems := []*types.MenuItem{ { - Label: utils.ResolvePlaceholderString(self.c.Tr.SimpleRebase, + Label: utils.ResolvePlaceholderString( + self.c.Tr.SimpleRebase, map[string]string{"ref": ref}, ), Keys: menuKey('s'), @@ -305,7 +306,8 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { }, }, { - Label: utils.ResolvePlaceholderString(self.c.Tr.InteractiveRebase, + Label: utils.ResolvePlaceholderString( + self.c.Tr.InteractiveRebase, map[string]string{"ref": ref}, ), Keys: menuKey('i'), @@ -331,7 +333,8 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { }, }, { - Label: utils.ResolvePlaceholderString(self.c.Tr.RebaseOntoBaseBranch, + Label: utils.ResolvePlaceholderString( + self.c.Tr.RebaseOntoBaseBranch, map[string]string{"baseBranch": ShortBranchName(baseBranch)}, ), Keys: menuKey('b'), diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index d27b38feb4f..835d936ac9f 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -503,7 +503,8 @@ func (self *RefreshHelper) refreshBranches(refreshWorktrees bool, keepBranchSele self.refreshStatus() return nil }) - }) + }, + ) if err != nil { self.c.Log.Error(err) } diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 9061d517729..989c33fce03 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -72,6 +72,8 @@ type WindowArrangementArgs struct { InSearchPrompt bool // One of '' (not searching), 'Search: ', and 'Filter: ' SearchPrefix string + // The height of the content of the currently focused side window + CurrentSideContextContentHeight int } func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions { @@ -85,21 +87,27 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, searchPrefix = self.c.Tr.SearchPrefix } + currentSideContentHeight := 0 + if currentSide := self.c.Context().CurrentSide(); currentSide != nil { + currentSideContentHeight = currentSide.TotalContentHeight() + } + args := WindowArrangementArgs{ - Width: width, - Height: height, - UserConfig: self.c.UserConfig(), - CurrentWindow: self.c.Context().CurrentStatic().GetWindowName(), - CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), - SplitMainPanel: repoState.GetSplitMainPanel(), - ScreenMode: repoState.GetScreenMode(), - AppStatus: appStatus, - InformationStr: informationStr, - ShowExtrasWindow: self.c.State().GetShowExtrasWindow(), - InDemo: self.c.InDemo(), - IsAnyModeActive: self.modeHelper.IsAnyModeActive(), - InSearchPrompt: repoState.InSearchPrompt(), - SearchPrefix: searchPrefix, + Width: width, + Height: height, + UserConfig: self.c.UserConfig(), + CurrentWindow: self.c.Context().CurrentStatic().GetWindowName(), + CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), + SplitMainPanel: repoState.GetSplitMainPanel(), + ScreenMode: repoState.GetScreenMode(), + AppStatus: appStatus, + InformationStr: informationStr, + ShowExtrasWindow: self.c.State().GetShowExtrasWindow(), + InDemo: self.c.InDemo(), + IsAnyModeActive: self.modeHelper.IsAnyModeActive(), + InSearchPrompt: repoState.InSearchPrompt(), + SearchPrefix: searchPrefix, + CurrentSideContextContentHeight: currentSideContentHeight, } return GetWindowDimensions(args) @@ -447,6 +455,26 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [ accordionMode := args.UserConfig.Gui.ExpandFocusedSidePanel accordionBox := func(defaultBox *boxlayout.Box) *boxlayout.Box { if accordionMode && defaultBox.Window == args.CurrentSideWindow { + staticSpace := 3 // status + numWeightedPanels := 3 // files, branches, commits + if args.CurrentSideWindow == "stash" { + numWeightedPanels = 4 + } else { + staticSpace += 3 // stash is static when not focused + } + + totalWeight := float64(args.UserConfig.Gui.ExpandedSidePanelWeight + numWeightedPanels - 1) + availableSpace := height - staticSpace + maxHeight := int(float64(availableSpace) * float64(args.UserConfig.Gui.ExpandedSidePanelWeight) / totalWeight) + contentHeight := args.CurrentSideContextContentHeight + 2 // +2 for borders + + if args.UserConfig.Gui.ExpandedFocusedSidePanelFitsContent && contentHeight < maxHeight { + return &boxlayout.Box{ + Window: defaultBox.Window, + Size: contentHeight, + } + } + return &boxlayout.Box{ Window: defaultBox.Window, Weight: args.UserConfig.Gui.ExpandedSidePanelWeight, diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index c63755ef24e..6e7e57fb513 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -121,10 +121,53 @@ func TestGetWindowDimensions(t *testing.T) { B: information `, }, + { + name: "expandedFocusedSidePanelFitsContent", + mutateArgs: func(args *WindowArrangementArgs) { + args.UserConfig.Gui.ExpandFocusedSidePanel = true + args.UserConfig.Gui.ExpandedFocusedSidePanelFitsContent = true + args.CurrentSideContextContentHeight = 2 + }, + expected: ` + ╭status─────────────────╮╭main────────────────────────────────────────────╮ + │ ││ │ + ╰───────────────────────╯│ │ + ╭files──────────────────╮│ │ + │ ││ │ + │ ││ │ + ╰───────────────────────╯│ │ + ╭branches───────────────╮│ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + ╰───────────────────────╯│ │ + ╭commits────────────────╮│ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + │ ││ │ + ╰───────────────────────╯│ │ + ╭stash──────────────────╮│ │ + │ ││ │ + ╰───────────────────────╯╰────────────────────────────────────────────────╯ + A + A: statusSpacer1 + B: information + `, + }, { name: "expandFocusedSidePanel", mutateArgs: func(args *WindowArrangementArgs) { args.UserConfig.Gui.ExpandFocusedSidePanel = true + args.CurrentSideContextContentHeight = 1000 }, expected: ` ╭status─────────────────╮╭main────────────────────────────────────────────╮ @@ -166,6 +209,7 @@ func TestGetWindowDimensions(t *testing.T) { mutateArgs: func(args *WindowArrangementArgs) { args.UserConfig.Gui.ExpandFocusedSidePanel = true args.UserConfig.Gui.ExpandedSidePanelWeight = 4 + args.CurrentSideContextContentHeight = 1000 }, expected: ` ╭status─────────────────╮╭main────────────────────────────────────────────╮ diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index b2d45679b19..14685d7aa72 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -282,7 +282,8 @@ func (self *ListController) GetKeybindings(opts types.KeybindingsOpts) []*types. } if self.context.RangeSelectEnabled() { - bindings = append(bindings, + bindings = append( + bindings, []*types.Binding{ {Tag: "navigation", Keys: opts.GetKeys(opts.Config.Universal.ToggleRangeSelect), Handler: self.HandleToggleRangeSelect, Description: self.c.Tr.ToggleRangeSelect}, {Tag: "navigation", Keys: opts.GetKeys(opts.Config.Universal.RangeSelectDown), Handler: self.HandleRangeSelectDown, Description: self.c.Tr.RangeSelectDown}, diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 4ab436bbc25..ac42ded1cc0 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -297,10 +297,13 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() { self.c.Tr.UpdateRefHere, map[string]string{ "ref": strings.TrimPrefix(commit.Name, "refs/heads/"), - })) + }, + ), + ) } else if commit.Action == todo.Exec { task = types.NewRenderStringTask( - self.c.Tr.ExecCommandHere + "\n\n" + commit.Name) + self.c.Tr.ExecCommandHere + "\n\n" + commit.Name, + ) } else { refRange := self.context().GetSelectedRefRangeForDiffFiles() task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange) @@ -451,7 +454,8 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error { func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepath string) error { if self.isSelectedHeadCommit() { return self.c.RunSubprocessAndRefresh( - self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath)) + self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath), + ) } err := self.c.Git().Rebase.BeginInteractiveRebaseForCommit(self.c.Model().Commits, self.context().GetSelectedLineIdx(), false) @@ -461,7 +465,8 @@ func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepat // now the selected commit should be our head so we'll amend it with the new message err = self.c.RunSubprocessAndRefresh( - self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath)) + self.c.Git().Commit.RewordLastCommitInEditorWithMessageFileCmdObj(filepath), + ) if err != nil { return err } @@ -598,7 +603,8 @@ func (self *LocalCommitsController) edit(selectedCommits []*models.Commit, start Mode: types.BLOCK_UI, Then: func() { self.restoreSelectionRangeAndMode(selectionRangeAndMode) }, - }) + }, + ) } return self.startInteractiveRebaseWithEdit(selectedCommits) @@ -638,7 +644,8 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit( } self.restoreSelectionRangeAndMode(selectionRangeAndMode) - }}) + }}, + ) }) } @@ -780,7 +787,8 @@ func (self *LocalCommitsController) moveDown(selectedCommits []*models.Commit, s self.context().HandleFocus(types.OnFocusOpts{ScrollSelectionIntoView: true}) } return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( - err, types.RefreshOptions{Mode: types.SYNC}) + err, types.RefreshOptions{Mode: types.SYNC}, + ) }) } @@ -806,7 +814,8 @@ func (self *LocalCommitsController) moveUp(selectedCommits []*models.Commit, sta self.context().HandleFocus(types.OnFocusOpts{ScrollSelectionIntoView: true}) } return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( - err, types.RefreshOptions{Mode: types.SYNC}) + err, types.RefreshOptions{Mode: types.SYNC}, + ) }) } @@ -941,7 +950,8 @@ func (self *LocalCommitsController) revert(commits []*models.Commit, start, end self.c.Tr.ConfirmRevertCommit, map[string]string{ "selectedCommit": commits[0].ShortHash(), - }) + }, + ) } else { promptText = self.c.Tr.ConfirmRevertCommitRange } @@ -1168,7 +1178,8 @@ func (self *LocalCommitsController) squashFixupsImpl(commit *models.Commit, reba err := self.c.Git().Rebase.SquashAllAboveFixupCommits(commit) self.context().MoveSelectedLine(-selectionOffset) return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( - err, types.RefreshOptions{Mode: types.SYNC}) + err, types.RefreshOptions{Mode: types.SYNC}, + ) }) } diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index dd8c89fff00..8039bb977b2 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -229,7 +229,8 @@ func (self *PatchBuildingController) discardSelectionFromCommit() error { err := self.c.Git().Patch.DeletePatchesFromCommit(self.c.Model().Commits, commitIndex) self.c.Helpers().PatchBuilding.Escape() return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( - err, types.RefreshOptions{Mode: types.SYNC}) + err, types.RefreshOptions{Mode: types.SYNC}, + ) }) } diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go index 3a49c01147e..c4015a9788d 100644 --- a/pkg/gui/controllers/remote_branches_controller.go +++ b/pkg/gui/controllers/remote_branches_controller.go @@ -156,7 +156,8 @@ func (self *RemoteBranchesController) createSortMenu() error { } return nil }, - self.c.UserConfig().Git.RemoteBranchSortOrder) + self.c.UserConfig().Git.RemoteBranchSortOrder, + ) } func (self *RemoteBranchesController) createResetMenu(selectedBranch *models.RemoteBranch) error { diff --git a/pkg/gui/controllers/scroll_off_margin.go b/pkg/gui/controllers/scroll_off_margin.go index ec155158231..e72e390a051 100644 --- a/pkg/gui/controllers/scroll_off_margin.go +++ b/pkg/gui/controllers/scroll_off_margin.go @@ -12,7 +12,8 @@ func checkScrollUp(view types.IViewTrait, userConfig *config.UserConfig, lineIdx viewPortStart, viewPortHeight := view.ViewPortYBounds() linesToScroll := calculateLinesToScrollUp( - viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) + viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter, + ) if linesToScroll != 0 { view.ScrollUp(linesToScroll) } @@ -26,7 +27,8 @@ func checkScrollDown(view types.IViewTrait, userConfig *config.UserConfig, lineI viewPortStart, viewPortHeight := view.ViewPortYBounds() linesToScroll := calculateLinesToScrollDown( - viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter) + viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter, + ) if linesToScroll != 0 { view.ScrollDown(linesToScroll) } diff --git a/pkg/gui/controllers/shell_command_action.go b/pkg/gui/controllers/shell_command_action.go index 114c7fcb167..ca4673e8686 100644 --- a/pkg/gui/controllers/shell_command_action.go +++ b/pkg/gui/controllers/shell_command_action.go @@ -49,7 +49,8 @@ func (self *ShellCommandAction) Call() error { } self.c.GetAppState().ShellCommandsHistory = slices.Delete( - self.c.GetAppState().ShellCommandsHistory, fullIndex, fullIndex+1) + self.c.GetAppState().ShellCommandsHistory, fullIndex, fullIndex+1, + ) self.c.SaveAppStateAndLogError() self.c.Contexts().Suggestions.RefreshSuggestions() return nil diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go index f29ee97f07c..fc92dd3f014 100644 --- a/pkg/gui/controllers/status_controller.go +++ b/pkg/gui/controllers/status_controller.go @@ -243,7 +243,8 @@ func (self *StatusController) showDashboard() { fmt.Sprintf("Raise an Issue: %s", constants.Links.Issues), fmt.Sprintf("Release Notes: %s", constants.Links.Releases), style.FgMagenta.Sprintf("Become a sponsor: %s", constants.Links.Donate), // caffeine ain't free - }, "\n\n") + "\n" + }, "\n\n", + ) + "\n" self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index c2ff4d6747d..33c81413836 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -98,7 +98,8 @@ func (self *SwitchToDiffFilesController) enter() error { path = filterPath } commitFilesContext.CommitFileTreeViewModel.SelectPath( - filepath.ToSlash(path), self.c.UserConfig().Gui.ShowRootItemInFileTree) + filepath.ToSlash(path), self.c.UserConfig().Gui.ShowRootItemInFileTree, + ) } self.c.Context().Push(commitFilesContext, types.OnFocusOpts{}) diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 649b5333899..912e522b009 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -204,7 +204,8 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts) UpstreamRemote: opts.upstreamRemote, UpstreamBranch: opts.upstreamBranch, SetUpstream: opts.setUpstream, - }) + }, + ) if err != nil { if !opts.force && !opts.forceWithLease && strings.Contains(err.Error(), "Updates were rejected") { if opts.remoteBranchStoredLocally { diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 9a900525401..5a5a704106c 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -50,7 +50,8 @@ func (self *FilesController) createResetMenu() error { ) return nil }, - }) + }, + ) return nil }, Keys: menuKey('x'), diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 3c4896af4c2..5c3b05d98d7 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -131,7 +131,8 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error { func (gui *Gui) handleCopySelectedSideContextItemCommitHashToClipboard() error { return gui.handleCopySelectedSideContextItemToClipboardWithTruncation( - gui.UserConfig().Git.TruncateCopiedCommitHashesTo) + gui.UserConfig().Git.TruncateCopiedCommitHashesTo, + ) } func (gui *Gui) handleCopySelectedSideContextItemToClipboardWithTruncation(maxWidth int) error { diff --git a/pkg/gui/options_map.go b/pkg/gui/options_map.go index 962187bfff8..4aa3cedb043 100644 --- a/pkg/gui/options_map.go +++ b/pkg/gui/options_map.go @@ -43,7 +43,8 @@ func (self *OptionsMapMgr) renderContextOptionsMap() { currentContextKeys := set.NewFromSlice( lo.FlatMap(currentContextBindings, func(binding *types.Binding, _ int) []gocui.Key { return binding.Keys - })) + }), + ) allBindings := append(currentContextBindings, lo.Filter(globalBindings, func(b *types.Binding, _ int) bool { return len(b.Keys) > 0 && !currentContextKeys.Includes(b.Keys[0]) diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index 5f1a29e6171..ba0551b8431 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -163,7 +163,8 @@ func (s *State) ToggleSelectHunk() { // If we are not currently on a change line, select the next one (or the // previous one if there is no next one): s.selectedLineIdx = s.viewLineIndices[s.patch.GetNextChangeIdx( - s.patchLineIndices[s.selectedLineIdx])] + s.patchLineIndices[s.selectedLineIdx], + )] } } @@ -425,7 +426,8 @@ func (s *State) CalculateOrigin(currentOrigin int, bufferHeight int, numLines in func wrapPatchLines(diff string, view *gocui.View) ([]int, []int) { _, viewLineIndices, patchLineIndices := utils.WrapViewLinesToWidth( - view.Wrap, view.Editable, strings.TrimSuffix(diff, "\n"), view.InnerWidth(), view.TabWidth) + view.Wrap, view.Editable, strings.TrimSuffix(diff, "\n"), view.InnerWidth(), view.TabWidth, + ) return viewLineIndices, patchLineIndices } diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go index 2e8ab01065a..30bf3ef94d2 100644 --- a/pkg/gui/presentation/branches.go +++ b/pkg/gui/presentation/branches.go @@ -175,7 +175,8 @@ func getBranchDisplayStrings( if fullDescription { res = append( res, - fmt.Sprintf("%s %s", + fmt.Sprintf( + "%s %s", style.FgYellow.Sprint(b.UpstreamRemote), style.FgYellow.Sprint(b.UpstreamBranch), ), diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 67fa62ac82c..6132ee63343 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -85,7 +85,8 @@ func GetCommitListDisplayStrings( allGraphLines := []string{} _, localSectionStart, found := lo.FindIndexOf( - commits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft }) + commits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft }, + ) if !found { localSectionStart = len(commits) } @@ -409,7 +410,8 @@ func displayCommit( // Don't show branch head on a "pick" todo if the rebase.updateRefs config is on !(commit.IsTODO() && hasRebaseUpdateRefsConfig) { tagString = style.FgCyan.SetBold().Sprint( - lo.Ternary(icons.IsIconEnabled(), icons.BRANCH_ICON, "*") + " " + tagString) + lo.Ternary(icons.IsIconEnabled(), icons.BRANCH_ICON, "*") + " " + tagString, + ) } } diff --git a/pkg/gui/presentation/worktrees.go b/pkg/gui/presentation/worktrees.go index b2d99cb95ca..7232ee14ed4 100644 --- a/pkg/gui/presentation/worktrees.go +++ b/pkg/gui/presentation/worktrees.go @@ -14,7 +14,8 @@ func GetWorktreeDisplayStrings(tr *i18n.TranslationSet, worktrees []*models.Work return lo.Map(worktrees, func(worktree *models.Worktree, _ int) []string { return GetWorktreeDisplayString( tr, - worktree) + worktree, + ) }) } diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go index 2ba381078bd..297594fcacb 100644 --- a/pkg/gui/test_mode.go +++ b/pkg/gui/test_mode.go @@ -36,7 +36,8 @@ func (gui *Gui) handleTestMode() { toastChan := make(chan string, 100) gui.PopupHandler.(*popup.PopupHandler).SetToastFunc( - func(message string, kind types.ToastKind) { toastChan <- message }) + func(message string, kind types.ToastKind) { toastChan <- message }, + ) test.Run(&GuiDriver{gui: gui, isIdleChan: isIdleChan, toastChan: toastChan, headless: Headless()}) diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 453ccd6c932..0441200a44c 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -32,7 +32,8 @@ func (gui *Gui) linesToReadFromCmdTask(v *gocui.View) tasks.LinesToRead { linesToReadForAccurateScrollbar := min( // However, cap it at some arbitrary max limit, so that we don't get // performance problems for huge monitors or tiny font sizes - height*(height-1)/minScrollbarHeight+oy, 5000) + height*(height-1)/minScrollbarHeight+oy, 5000, + ) return tasks.LinesToRead{ Total: linesToReadForAccurateScrollbar, diff --git a/pkg/integration/components/test_driver.go b/pkg/integration/components/test_driver.go index 8294f3b46fa..2ce1a0786fb 100644 --- a/pkg/integration/components/test_driver.go +++ b/pkg/integration/components/test_driver.go @@ -107,7 +107,8 @@ func (self *TestDriver) ExpectToast(matcher *TextMatcher) *TestDriver { if t == nil { self.gui.Fail("Expected toast, but didn't get one") } else { - self.matchString(matcher, "Unexpected toast message", + self.matchString( + matcher, "Unexpected toast message", func() string { return *t }, diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index e9e5fbbc70e..9b95abbd718 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -259,7 +259,8 @@ func (self *ViewDriver) assertLines(offset int, matchers ...*TextMatcher) *ViewD lineIdx := matcherIndex + offset expectSelected, matcher := matcher.checkIsSelected() - self.t.matchString(matcher, fmt.Sprintf("Unexpected content in view '%s'.", view.Name()), + self.t.matchString( + matcher, fmt.Sprintf("Unexpected content in view '%s'.", view.Name()), func() string { return view.BufferLines()[lineIdx] }, @@ -304,7 +305,8 @@ func formatLineRange(from int, to int) string { // asserts on the content of the view i.e. the stuff within the view's frame. func (self *ViewDriver) Content(matcher *TextMatcher) *ViewDriver { - self.t.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context), + self.t.matchString( + matcher, fmt.Sprintf("%s: Unexpected content.", self.context), func() string { return self.getView().Buffer() }, diff --git a/pkg/integration/tests/branch/open_pull_request_select_remote_and_target_branch.go b/pkg/integration/tests/branch/open_pull_request_select_remote_and_target_branch.go index ac744210f80..8cca1b7a5f9 100644 --- a/pkg/integration/tests/branch/open_pull_request_select_remote_and_target_branch.go +++ b/pkg/integration/tests/branch/open_pull_request_select_remote_and_target_branch.go @@ -50,7 +50,8 @@ var OpenPullRequestSelectRemoteAndTargetBranch = NewIntegrationTest(NewIntegrati Title(Equals("Select target remote")). SuggestionLines( Equals("origin"), - Equals("upstream")). + Equals("upstream"), + ). ConfirmSuggestion(Equals("upstream")) // Verify that we're prompted to enter the target branch and that only those branches @@ -60,7 +61,8 @@ var OpenPullRequestSelectRemoteAndTargetBranch = NewIntegrationTest(NewIntegrati Title(Equals("branch-2 → upstream/")). SuggestionLines( Equals("branch-1"), - Equals("master")). + Equals("master"), + ). ConfirmSuggestion(Equals("master")) // Verify that the expected URL is used (by checking the openlink file) @@ -69,6 +71,7 @@ var OpenPullRequestSelectRemoteAndTargetBranch = NewIntegrationTest(NewIntegrati // the link is not yet correct. Thus, this test is expected to fail once this is fixed. t.FileSystem().FileContent( "/tmp/openlink", - Equals("https://github.com/my-personal-fork/lazygit/compare/master...branch-2?expand=1\n")) + Equals("https://github.com/my-personal-fork/lazygit/compare/master...branch-2?expand=1\n"), + ) }, }) diff --git a/pkg/integration/tests/commit/amend.go b/pkg/integration/tests/commit/amend.go index a67705fd440..e450e05f924 100644 --- a/pkg/integration/tests/commit/amend.go +++ b/pkg/integration/tests/commit/amend.go @@ -26,7 +26,8 @@ var Amend = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Commits.AmendToCommit) t.ExpectPopup().Confirmation().Title( - Equals("Amend last commit")). + Equals("Amend last commit"), + ). Content(Contains("Are you sure you want to amend last commit?")). Confirm() diff --git a/pkg/integration/tests/commit/auto_wrap_message.go b/pkg/integration/tests/commit/auto_wrap_message.go index f65c182266a..4b32bad0f28 100644 --- a/pkg/integration/tests/commit/auto_wrap_message.go +++ b/pkg/integration/tests/commit/auto_wrap_message.go @@ -41,7 +41,8 @@ var AutoWrapMessage = NewIntegrationTest(NewIntegrationTestArgs{ Focus(). Tap(func() { t.Views().Main().Content(Contains( - "subject\n \n Lorem ipsum dolor\n sit amet,\n consectetur\n adipiscing elit.")) + "subject\n \n Lorem ipsum dolor\n sit amet,\n consectetur\n adipiscing elit.", + )) }). Press(keys.Commits.RenameCommit) diff --git a/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go index 1a09cea7af9..fbfc806db83 100644 --- a/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go +++ b/pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go @@ -45,13 +45,15 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ t.Views().Information().Content(Contains("Building patch")) t.Views().Secondary().Content( - Contains("+more file1 content")) + Contains("+more file1 content"), + ) }). SelectNextItem(). PressPrimaryAction() t.Views().Secondary().Content( - Contains("+more file1 content").Contains("+more file2 content")) + Contains("+more file1 content").Contains("+more file2 content"), + ) t.Common().SelectPatchOption(Contains("Apply patch in reverse")) diff --git a/pkg/integration/tests/ui/keybinding_suggestions_dont_crash_on_disabled_bindings.go b/pkg/integration/tests/ui/keybinding_suggestions_dont_crash_on_disabled_bindings.go index 1db31595f1e..57465fa9355 100644 --- a/pkg/integration/tests/ui/keybinding_suggestions_dont_crash_on_disabled_bindings.go +++ b/pkg/integration/tests/ui/keybinding_suggestions_dont_crash_on_disabled_bindings.go @@ -16,6 +16,7 @@ var KeybindingSuggestionsDontCrashOnDisabledBindings = NewIntegrationTest(NewInt Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Files().Focus() t.Views().Options().Content( - Equals("Commit: c | Reset: D | Keybindings: ?")) + Equals("Commit: c | Reset: D | Keybindings: ?"), + ) }, }) diff --git a/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go index def9a53c742..4353466de97 100644 --- a/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go +++ b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go @@ -31,12 +31,14 @@ var KeybindingSuggestionsWhenSwitchingRepos = NewIntegrationTest(NewIntegrationT t.Views().Files().Focus() t.Views().Options().Content( - Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?")) + Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?"), + ) switchToRepo("other") switchToRepo("repo") t.Views().Options().Content( - Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?")) + Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?"), + ) }, }) diff --git a/pkg/integration/tests/worktree/crud.go b/pkg/integration/tests/worktree/crud.go index cd539d10b42..ab253e48ddd 100644 --- a/pkg/integration/tests/worktree/crud.go +++ b/pkg/integration/tests/worktree/crud.go @@ -35,7 +35,7 @@ var Crud = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). - Select(Contains(`Create worktree from ref`).DoesNotContain(("detached"))). + Select(Contains(`Create worktree from ref`).DoesNotContain("detached")). Confirm() t.ExpectPopup().Prompt(). diff --git a/pkg/integration/tests/worktree/worktree_in_repo.go b/pkg/integration/tests/worktree/worktree_in_repo.go index 5f0ee66ec18..8a0202c4231 100644 --- a/pkg/integration/tests/worktree/worktree_in_repo.go +++ b/pkg/integration/tests/worktree/worktree_in_repo.go @@ -30,7 +30,7 @@ var WorktreeInRepo = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Worktree")). - Select(Contains(`Create worktree from ref`).DoesNotContain(("detached"))). + Select(Contains(`Create worktree from ref`).DoesNotContain("detached")). Confirm() t.ExpectPopup().Prompt(). diff --git a/pkg/jsonschema/generate_config_docs.go b/pkg/jsonschema/generate_config_docs.go index ba245e99ab0..d51c30d8955 100644 --- a/pkg/jsonschema/generate_config_docs.go +++ b/pkg/jsonschema/generate_config_docs.go @@ -111,7 +111,8 @@ func setComment(yamlNode *yaml.Node, description string) { } return "# " + s }), - "\n") + "\n", + ) } func (n *Node) MarshalYAML() (any, error) { diff --git a/pkg/snake/snake.go b/pkg/snake/snake.go index 62fc0ddfd2a..7dd2e079ccc 100644 --- a/pkg/snake/snake.go +++ b/pkg/snake/snake.go @@ -20,7 +20,7 @@ type Game struct { exit chan (struct{}) // channel for specifying the direction the player wants the snake to go in - setNewDir chan (Direction) + setNewDir chan Direction // allows logging for debugging logger func(string) diff --git a/pkg/utils/date.go b/pkg/utils/date.go index f0303a9c498..502c1fa319f 100644 --- a/pkg/utils/date.go +++ b/pkg/utils/date.go @@ -42,14 +42,16 @@ func formatSecondsAgo(secondsAgo int64) string { } if secondsAgo < period.secondsInPeriod { - return fmt.Sprintf("%d%s", + return fmt.Sprintf( + "%d%s", secondsAgo/periods[i-1].secondsInPeriod, periods[i-1].label, ) } } - return fmt.Sprintf("%d%s", + return fmt.Sprintf( + "%d%s", secondsAgo/periods[len(periods)-1].secondsInPeriod, periods[len(periods)-1].label, ) diff --git a/pkg/utils/rebase_todo_test.go b/pkg/utils/rebase_todo_test.go index 9daf7db01c1..ebc1d126e2c 100644 --- a/pkg/utils/rebase_todo_test.go +++ b/pkg/utils/rebase_todo_test.go @@ -171,15 +171,16 @@ func TestRebaseCommands_moveTodoDown(t *testing.T) { } for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - rearrangedTodos, err := moveTodoDown(s.todos, s.todoToMoveDown, s.isInRebase) - if s.expectedErr == "" { - assert.NoError(t, err) - } else { - assert.ErrorContains(t, err, s.expectedErr) - } - assert.Equal(t, s.expectedTodos, rearrangedTodos) - }, + t.Run( + s.testName, func(t *testing.T) { + rearrangedTodos, err := moveTodoDown(s.todos, s.todoToMoveDown, s.isInRebase) + if s.expectedErr == "" { + assert.NoError(t, err) + } else { + assert.ErrorContains(t, err, s.expectedErr) + } + assert.Equal(t, s.expectedTodos, rearrangedTodos) + }, ) } } @@ -346,15 +347,16 @@ func TestRebaseCommands_moveTodoUp(t *testing.T) { } for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - rearrangedTodos, err := moveTodoUp(s.todos, s.todoToMoveUp, s.isInRebase) - if s.expectedErr == "" { - assert.NoError(t, err) - } else { - assert.ErrorContains(t, err, s.expectedErr) - } - assert.Equal(t, s.expectedTodos, rearrangedTodos) - }, + t.Run( + s.testName, func(t *testing.T) { + rearrangedTodos, err := moveTodoUp(s.todos, s.todoToMoveUp, s.isInRebase) + if s.expectedErr == "" { + assert.NoError(t, err) + } else { + assert.ErrorContains(t, err, s.expectedErr) + } + assert.Equal(t, s.expectedTodos, rearrangedTodos) + }, ) } } diff --git a/pkg/utils/template.go b/pkg/utils/template.go index f5fea99e443..b6445b74b4f 100644 --- a/pkg/utils/template.go +++ b/pkg/utils/template.go @@ -24,7 +24,8 @@ func ResolveTemplate(templateStr string, object any, funcs template.FuncMap) (st func ResolvePlaceholderString(str string, arguments map[string]string) string { oldnews := make([]string, 0, len(arguments)*4) for key, value := range arguments { - oldnews = append(oldnews, + oldnews = append( + oldnews, "{{"+key+"}}", value, "{{."+key+"}}", value, ) diff --git a/schema-master/config.json b/schema-master/config.json index b95c5c98053..0c6f6058595 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -585,6 +585,11 @@ "description": "The weight of the expanded side panel, relative to the other panels. 2 means twice as tall as the other panels. Only relevant if `expandFocusedSidePanel` is true.", "default": 2 }, + "expandedFocusedSidePanelFitsContent": { + "type": "boolean", + "description": "If true, the expanded side panel will only expand as much as its content requires. Only relevant if `expandFocusedSidePanel` is true.", + "default": false + }, "mainPanelSplitMode": { "type": "string", "enum": [