diff options
30 files changed, 395 insertions, 456 deletions
diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index 09a933f81..82eafdb1d 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -10,21 +10,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>pgdown</kbd>: scroll down main panel (fn+down) <kbd>m</kbd>: view merge/rebase options <kbd>ctrl+p</kbd>: view custom patch options - <kbd>P</kbd>: push - <kbd>p</kbd>: pull <kbd>R</kbd>: refresh <kbd>x</kbd>: open menu - <kbd>z</kbd>: undo (via reflog) (experimental) - <kbd>ctrl+z</kbd>: redo (via reflog) (experimental) <kbd>+</kbd>: next screen mode (normal/half/fullscreen) <kbd>_</kbd>: prev screen mode - <kbd>:</kbd>: execute custom command <kbd>ctrl+s</kbd>: view filter-by-path options <kbd>W</kbd>: open diff menu <kbd>ctrl+e</kbd>: open diff menu <kbd>@</kbd>: open command log menu <kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view + <kbd>z</kbd>: undo (via reflog) (experimental) + <kbd>ctrl+z</kbd>: redo (via reflog) (experimental) + <kbd>P</kbd>: push + <kbd>p</kbd>: pull </pre> ## List Panel Navigation @@ -170,20 +169,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>@</kbd>: open command log menu </pre> -## Files Panel - -<pre> - <kbd>ctrl+b</kbd>: Filter commit files -</pre> - ## Files Panel (Files) <pre> + <kbd>d</kbd>: view 'discard changes' options + <kbd>D</kbd>: view reset options + <kbd>f</kbd>: fetch + <kbd>ctrl+o</kbd>: copy the file name to the clipboard + <kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view + <kbd>space</kbd>: toggle staged + <kbd>ctrl+b</kbd>: Filter files (staged/unstaged) <kbd>c</kbd>: commit changes <kbd>w</kbd>: commit changes without pre-commit hook <kbd>A</kbd>: amend last commit <kbd>C</kbd>: commit changes using git editor - <kbd>d</kbd>: view 'discard changes' options <kbd>e</kbd>: edit file <kbd>o</kbd>: open file <kbd>i</kbd>: add to .gitignore @@ -191,15 +190,11 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>s</kbd>: stash changes <kbd>S</kbd>: view stash options <kbd>a</kbd>: stage/unstage all - <kbd>D</kbd>: view reset options <kbd>enter</kbd>: stage individual hunks/lines for file, or collapse/expand for directory - <kbd>f</kbd>: fetch - <kbd>ctrl+o</kbd>: copy the file name to the clipboard + <kbd>:</kbd>: execute custom command <kbd>g</kbd>: view upstream reset options <kbd>`</kbd>: toggle file tree view <kbd>M</kbd>: open external merge tool (git mergetool) - <kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view - <kbd>space</kbd>: toggle staged </pre> ## Files Panel (Submodules) diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 5e0d62fac..0136a529b 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -10,12 +10,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>pgdown</kbd>: scroll naar beneden vanaf hoofdpaneel (fn+down) <kbd>m</kbd>: bekijk merge/rebase opties <kbd>ctrl+p</kbd>: bekijk aangepaste patch opties - <kbd>P</kbd>: push - <kbd>p</kbd>: pull <kbd>R</kbd>: verversen <kbd>x</kbd>: open menu - <kbd>z</kbd>: ongedaan maken (via reflog) (experimenteel) - <kbd>ctrl+z</kbd>: redo (via reflog) (experimenteel) <kbd>+</kbd>: volgende scherm modus (normaal/half/groot) <kbd>_</kbd>: vorige scherm modus <kbd>:</kbd>: voer aangepaste commando uit @@ -25,6 +21,10 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>@</kbd>: open command log menu <kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view + <kbd>z</kbd>: ongedaan maken (via reflog) (experimenteel) + <kbd>ctrl+z</kbd>: redo (via reflog) (experimenteel) + <kbd>P</kbd>: push + <kbd>p</kbd>: pull </pre> ## Lijstpaneel Navigatie @@ -170,12 +170,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>@</kbd>: open command log menu </pre> -## Bestanden Paneel - -<pre> - <kbd>ctrl+b</kbd>: Commit dossiers filteren -</pre> - ## Bestanden Paneel (Bestanden) <pre> @@ -183,7 +177,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>w</kbd>: commit veranderingen zonder pre-commit hook <kbd>A</kbd>: wijzig laatste commit <kbd>C</kbd>: commit veranderingen met de git editor - <kbd>d</kbd>: bekijk 'veranderingen ongedaan maken' opties <kbd>e</kbd>: verander bestand <kbd>o</kbd>: open bestand <kbd>i</kbd>: voeg toe aan .gitignore @@ -191,15 +184,11 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>s</kbd>: stash-bestanden <kbd>S</kbd>: bekijk stash opties <kbd>a</kbd>: toggle staged alle - <kbd>D</kbd>: bekijk reset opties <kbd>enter</kbd>: stage individuele hunks/lijnen - <kbd>f</kbd>: fetch - <kbd>ctrl+o</kbd>: kopieer de bestandsnaam naar het klembord + <kbd>:</kbd>: voor aangepaste commando uit <kbd>g</kbd>: bekijk upstream reset opties <kbd>`</kbd>: toggle bestandsboom weergave <kbd>M</kbd>: open external merge tool (git mergetool) - <kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view - <kbd>space</kbd>: toggle staged </pre> ## Bestanden Paneel (Submodules) diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index afdcdebcd..1d7f4f725 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -10,21 +10,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>pgdown</kbd>: scroll down main panel (fn+down) <kbd>m</kbd>: widok scalenia/opcje zmiany bazy <kbd>ctrl+p</kbd>: view custom patch options - <kbd>P</kbd>: push - <kbd>p</kbd>: pull <kbd>R</kbd>: odśwież <kbd>x</kbd>: open menu - <kbd>z</kbd>: undo (via reflog) (experimental) - <kbd>ctrl+z</kbd>: redo (via reflog) (experimental) <kbd>+</kbd>: next screen mode (normal/half/fullscreen) <kbd>_</kbd>: prev screen mode - <kbd>:</kbd>: wykonaj własną komendę <kbd>ctrl+s</kbd>: view filter-by-path options <kbd>W</kbd>: open diff menu <kbd>ctrl+e</kbd>: open diff menu <kbd>@</kbd>: open command log menu <kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view + <kbd>z</kbd>: undo (via reflog) (experimental) + <kbd>ctrl+z</kbd>: redo (via reflog) (experimental) + <kbd>P</kbd>: push + <kbd>p</kbd>: pull </pre> ## List Panel Navigation @@ -170,20 +169,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>@</kbd>: open command log menu </pre> -## Pliki Panel - -<pre> - <kbd>ctrl+b</kbd>: Filtrowanie commitów -</pre> - ## Pliki Panel (Pliki) <pre> + <kbd>d</kbd>: pokaż opcje porzucania zmian + <kbd>D</kbd>: wyświetl opcje resetu + <kbd>f</kbd>: pobierz + <kbd>ctrl+o</kbd>: copy the file name to the clipboard + <kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view + <kbd>space</kbd>: przełącz stan poczekalni + <kbd>ctrl+b</kbd>: Filter files (staged/unstaged) <kbd>c</kbd>: Zatwierdź zmiany <kbd>w</kbd>: zatwierdź zmiany bez skryptu pre-commit <kbd>A</kbd>: Zmień ostatni commit <kbd>C</kbd>: Zatwierdź zmiany używając edytora - <kbd>d</kbd>: pokaż opcje porzucania zmian <kbd>e</kbd>: edytuj plik <kbd>o</kbd>: otwórz plik <kbd>i</kbd>: dodaj do .gitignore @@ -191,15 +190,11 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>s</kbd>: przechowaj zmiany <kbd>S</kbd>: wyświetl opcje schowka <kbd>a</kbd>: przełącz stan poczekalni wszystkich - <kbd>D</kbd>: wyświetl opcje resetu <kbd>enter</kbd>: zatwierdź pojedyncze linie - <kbd>f</kbd>: pobierz - <kbd>ctrl+o</kbd>: copy the file name to the clipboard + <kbd>:</kbd>: wykonaj własną komendę <kbd>g</kbd>: view upstream reset options <kbd>`</kbd>: toggle file tree view <kbd>M</kbd>: open external merge tool (git mergetool) - <kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view - <kbd>space</kbd>: przełącz stan poczekalni </pre> ## Pliki Panel (Submodules) diff --git a/docs/keybindings/Keybindings_zh.md b/docs/keybindings/Keybindings_zh.md index 61b2c287f..cba13cfc4 100644 --- a/docs/keybindings/Keybindings_zh.md +++ b/docs/keybindings/Keybindings_zh.md @@ -10,21 +10,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>pgdown</kbd>: 向下滚动主面板 (fn+down) <kbd>m</kbd>: 查看 合并/变基 选项 <kbd>ctrl+p</kbd>: 查看自定义补丁选项 - <kbd>P</kbd>: 推送 - <kbd>p</kbd>: 拉取 <kbd>R</kbd>: 刷新 <kbd>x</kbd>: 打开菜单 - <kbd>z</kbd>: (通过 reflog)撤销「实验功能」 - <kbd>ctrl+z</kbd>: (通过 reflog)重做「实验功能」 <kbd>+</kbd>: 下一屏模式(正常/半屏/全屏) <kbd>_</kbd>: 上一屏模式 - <kbd>:</kbd>: 执行自定义命令 <kbd>ctrl+s</kbd>: 查看按路径过滤选项 <kbd>W</kbd>: 打开 diff 菜单 <kbd>ctrl+e</kbd>: 打开 diff 菜单 <kbd>@</kbd>: 打开命令日志菜单 <kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view + <kbd>z</kbd>: (通过 reflog)撤销「实验功能」 + <kbd>ctrl+z</kbd>: (通过 reflog)重做「实验功能」 + <kbd>P</kbd>: 推送 + <kbd>p</kbd>: 拉取 </pre> ## 列表面板导航 @@ -170,20 +169,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>@</kbd>: 打开命令日志菜单 </pre> -## 文件 面板 - -<pre> - <kbd>ctrl+b</kbd>: 过滤提交文件 -</pre> - ## 文件 面板 (文件) <pre> + <kbd>d</kbd>: 查看'放弃更改‘选项 + <kbd>D</kbd>: 查看重置选项 + <kbd>f</kbd>: 抓取 + <kbd>ctrl+o</kbd>: 将文件名复制到剪贴板 + <kbd>ctrl+w</kbd>: 切换是否在差异视图中显示空白更改 + <kbd>space</kbd>: 切换暂存状态 + <kbd>ctrl+b</kbd>: Filter files (staged/unstaged) <kbd>c</kbd>: 提交更改 <kbd>w</kbd>: 提交更改而无需预先提交钩子 <kbd>A</kbd>: 修补最后一次提交 <kbd>C</kbd>: 提交更改(使用编辑器编辑提交信息) - <kbd>d</kbd>: 查看'放弃更改‘选项 <kbd>e</kbd>: 编辑文件 <kbd>o</kbd>: 打开文件 <kbd>i</kbd>: 添加到 .gitignore @@ -191,15 +190,11 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>s</kbd>: 将所有更改加入贮藏 <kbd>S</kbd>: 查看隐藏选项 <kbd>a</kbd>: 切换所有文件的暂存状态 - <kbd>D</kbd>: 查看重置选项 <kbd>enter</kbd>: 暂存单个 块/行 用于文件, 或 折叠/展开 目录 - <kbd>f</kbd>: 抓取 - <kbd>ctrl+o</kbd>: 将文件名复制到剪贴板 + <kbd>:</kbd>: 执行自定义命令 <kbd>g</kbd>: 查看上游重置选项 <kbd>`</kbd>: 切换文件树视图 <kbd>M</kbd>: 打开合并工具 - <kbd>ctrl+w</kbd>: 切换是否在差异视图中显示空白更改 - <kbd>space</kbd>: 切换暂存状态 </pre> ## 文件 面板 (子模块) @@ -14,7 +14,6 @@ require ( github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 // indirect github.com/go-errors/errors v1.4.1 github.com/go-logfmt/logfmt v0.5.0 // indirect - github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect github.com/golang/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gookit/color v1.4.2 @@ -45,6 +44,5 @@ require ( golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/text v0.3.7 // indirect gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0 ) @@ -33,7 +33,6 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57KM= github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b h1:eoaSI4eEwM5eTx/HvmRSwmicxuMhL73AyoEfM1oCJLc= github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b/go.mod h1:ZPwXnysybtQqdqKcWMWXux9aGdtMHe+kr+cwEZEe+A4= @@ -55,8 +54,6 @@ github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4= -github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go index b3e94e15f..b27514381 100644 --- a/pkg/gui/context_config.go +++ b/pkg/gui/context_config.go @@ -145,7 +145,7 @@ func (gui *Gui) contextTree() context.ContextTree { }, Merging: &BasicContext{ OnFocus: OnFocusWrapper(func() error { return gui.renderConflictsWithLock(true) }), - Kind: MAIN_CONTEXT, + Kind: types.MAIN_CONTEXT, ViewName: "main", Key: MAIN_MERGING_CONTEXT_KEY, OnGetOptionsMap: gui.getMergingOptions, diff --git a/pkg/gui/context_test.go b/pkg/gui/context_test.go index 7f03f7484..3a0aa120a 100644 --- a/pkg/gui/context_test.go +++ b/pkg/gui/context_test.go @@ -4,15 +4,16 @@ import ( "testing" "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/stretchr/testify/assert" ) func TestCanDeactivatePopupContextsWithoutViews(t *testing.T) { - contexts := []func(gui *Gui) Context{ - func(gui *Gui) Context { return gui.State.Contexts.Credentials }, - func(gui *Gui) Context { return gui.State.Contexts.Confirmation }, - func(gui *Gui) Context { return gui.State.Contexts.CommitMessage }, - func(gui *Gui) Context { return gui.State.Contexts.Search }, + contexts := []func(gui *Gui) types.Context{ + func(gui *Gui) types.Context { return gui.State.Contexts.Credentials }, + func(gui *Gui) types.Context { return gui.State.Contexts.Confirmation }, + func(gui *Gui) types.Context { return gui.State.Contexts.CommitMessage }, + func(gui *Gui) types.Context { return gui.State.Contexts.Search }, } for _, c := range contexts { diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 674e79f76..06602a445 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -13,9 +13,9 @@ import ( ) type BisectController struct { - c *ControllerCommon - context types.IListContext - git *commands.GitCommand + c *ControllerCommon + getContext func() types.IListContext + git *commands.GitCommand getSelectedLocalCommit func() *models.Commit getCommits func() []*models.Commit @@ -25,16 +25,16 @@ var _ types.IController = &BisectController{} func NewBisectController( c *ControllerCommon, - context types.IListContext, + getContext func() types.IListContext, git *commands.GitCommand, getSelectedLocalCommit func() *models.Commit, getCommits func() []*models.Commit, ) *BisectController { return &BisectController{ - c: c, - context: context, - git: git, + c: c, + getContext: getContext, + git: git, getSelectedLocalCommit: getSelectedLocalCommit, getCommits: getCommits, @@ -249,8 +249,8 @@ func (self *BisectController) selectCurrentBisectCommit() { // find index of commit with that sha, move cursor to that. for i, commit := range self.getCommits() { if commit.Sha == info.GetCurrentSha() { - self.context.GetPanelState().SetSelectedLineIdx(i) - _ = self.context.HandleFocus() + self.getContext().GetPanelState().SetSelectedLineIdx(i) + _ = self.getContext().HandleFocus() break } } @@ -269,5 +269,5 @@ func (self *BisectController) checkSelected(callback func(*models.Commit) error) } func (self *BisectController) Context() types.Context { - return self.context + return self.getContext() } diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 10d378f9f..8f4641147 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -22,14 +22,14 @@ type FilesController struct { // case I would actually prefer a _zero_ letter variable name in the form of // struct embedding, but Go does not allow hiding public fields in an embedded struct // to the client - c *ControllerCommon - context types.IListContext - git *commands.GitCommand - os *oscommands.OSCommand + c *ControllerCommon + getContext func() types.IListContext + git *commands.GitCommand + os *oscommands.OSCommand getSelectedFileNode func() *filetree.FileNode - allContexts context.ContextTree - fileTreeViewModel *filetree.FileTreeViewModel + getContexts func() context.ContextTree + getViewModel func() *filetree.FileTreeViewModel enterSubmodule func(submodule *models.SubmoduleConfig) error getSubmodules func() []*models.SubmoduleConfig setCommitMessage func(message string) @@ -49,12 +49,12 @@ var _ types.IController = &FilesController{} func NewFilesController( c *ControllerCommon, - context types.IListContext, + getContext func() types.IListContext, git *commands.GitCommand, os *oscommands.OSCommand, getSelectedFileNode func() *filetree.FileNode, - allContexts context.ContextTree, - fileTreeViewModel *filetree.FileTreeViewModel, + allContexts func() context.ContextTree, + getViewModel func() *filetree.FileTreeViewModel, enterSubmodule func(submodule *models.SubmoduleConfig) error, getSubmodules func() []*models.SubmoduleConfig, setCommitMessage func(message string), @@ -70,12 +70,12 @@ func NewFilesController( ) *FilesController { return &FilesController{ c: c, - context: context, + getContext: getContext, git: git, os: os, getSelectedFileNode: getSelectedFileNode, - allContexts: allContexts, - fileTreeViewModel: fileTreeViewModel, + getContexts: allContexts, + getViewModel: getViewModel, enterSubmodule: enterSubmodule, getSubmodules: getSubmodules, setCommitMessage: setCommitMessage, @@ -100,7 +100,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co }, { Key: gocui.MouseLeft, - Handler: func() error { return self.context.HandleClick(self.checkSelectedFileNode(self.press)) }, + Handler: func() error { return self.getContext().HandleClick(self.checkSelectedFileNode(self.press)) }, }, { Key: getKey("<c-b>"), // TODO: softcode @@ -129,7 +129,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co }, { Key: getKey(config.Universal.Edit), - Handler: self.edit, + Handler: self.checkSelectedFileNode(self.edit), Description: self.c.Tr.LcEditFile, }, { @@ -139,7 +139,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co }, { Key: getKey(config.Files.IgnoreFile), - Handler: self.ignore, + Handler: self.checkSelectedFileNode(self.ignore), Description: self.c.Tr.LcIgnoreFile, }, { @@ -192,7 +192,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co }, } - return append(bindings, self.context.Keybindings(getKey, config, guards)...) + return append(bindings, self.getContext().Keybindings(getKey, config, guards)...) } func (self *FilesController) press(node *filetree.FileNode) error { @@ -200,7 +200,7 @@ func (self *FilesController) press(node *filetree.FileNode) error { file := node.File if file.HasInlineMergeConflicts { - return self.c.PushContext(self.allContexts.Merging) + return self.c.PushContext(self.getContexts().Merging) } if file.HasUnstagedChanges { @@ -239,7 +239,7 @@ func (self *FilesController) press(node *filetree.FileNode) error { return err } - return self.context.HandleFocus() + return self.getContext().HandleFocus() } func (self *FilesController) checkSelectedFileNode(callback func(*filetree.FileNode) error) func() error { @@ -253,19 +253,8 @@ func (self *FilesController) checkSelectedFileNode(callback func(*filetree.FileN } } -func (self *FilesController) checkSelectedFile(callback func(*models.File) error) func() error { - return func() error { - file := self.getSelectedFile() - if file == nil { - return nil - } - - return callback(file) - } -} - func (self *FilesController) Context() types.Context { - return self.context + return self.getContext() } func (self *FilesController) getSelectedFile() *models.File { @@ -305,11 +294,11 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error { return self.c.ErrorMsg(self.c.Tr.FileStagingRequirements) } - return self.c.PushContext(self.allContexts.Staging, opts) + return self.c.PushContext(self.getContexts().Staging, opts) } func (self *FilesController) allFilesStaged() bool { - for _, file := range self.fileTreeViewModel.GetAllFiles() { + for _, file := range self.getViewModel().GetAllFiles() { if file.HasUnstagedChanges { return false } @@ -334,15 +323,10 @@ func (self *FilesController) stageAll() error { return err } - return self.allContexts.Files.HandleFocus() + return self.getContexts().Files.HandleFocus() } -func (self *FilesController) ignore() error { - node := self.getSelectedFileNode() - if node == nil { - return nil - } - +func (self *FilesController) ignore(node *filetree.FileNode) error { if node.GetPath() == ".gitignore" { return self.c.ErrorMsg("Cannot ignore .gitignore") } @@ -444,7 +428,7 @@ func (self *FilesController) HandleCommitPress() error { return self.c.Error(err) } - if self.fileTreeViewModel.GetItemsLength() == 0 { + if self.getViewModel().GetItemsLength() == 0 { return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) } @@ -469,7 +453,7 @@ func (self *FilesController) HandleCommitPress() error { } } - if err := self.c.PushContext(self.allContexts.CommitMessage); err != nil { + if err := self.c.Push |