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

fix some things

This commit is contained in:
Jesse Duffield 2022-01-23 14:40:28 +11:00
parent 1dd7307fde
commit a2318d75b5
30 changed files with 367 additions and 428 deletions

View File

@ -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>pgdown</kbd>: scroll down main panel (fn+down)
<kbd>m</kbd>: view merge/rebase options <kbd>m</kbd>: view merge/rebase options
<kbd>ctrl+p</kbd>: view custom patch options <kbd>ctrl+p</kbd>: view custom patch options
<kbd>P</kbd>: push
<kbd>p</kbd>: pull
<kbd>R</kbd>: refresh <kbd>R</kbd>: refresh
<kbd>x</kbd>: open menu <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>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode <kbd>_</kbd>: prev screen mode
<kbd>:</kbd>: execute custom command
<kbd>ctrl+s</kbd>: view filter-by-path options <kbd>ctrl+s</kbd>: view filter-by-path options
<kbd>W</kbd>: open diff menu <kbd>W</kbd>: open diff menu
<kbd>ctrl+e</kbd>: open diff menu <kbd>ctrl+e</kbd>: open diff menu
<kbd>@</kbd>: open command log menu <kbd>@</kbd>: open command log menu
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <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>{</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> </pre>
## List Panel Navigation ## 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 <kbd>@</kbd>: open command log menu
</pre> </pre>
## Files Panel
<pre>
<kbd>ctrl+b</kbd>: Filter commit files
</pre>
## Files Panel (Files) ## Files Panel (Files)
<pre> <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>c</kbd>: commit changes
<kbd>w</kbd>: commit changes without pre-commit hook <kbd>w</kbd>: commit changes without pre-commit hook
<kbd>A</kbd>: amend last commit <kbd>A</kbd>: amend last commit
<kbd>C</kbd>: commit changes using git editor <kbd>C</kbd>: commit changes using git editor
<kbd>d</kbd>: view 'discard changes' options
<kbd>e</kbd>: edit file <kbd>e</kbd>: edit file
<kbd>o</kbd>: open file <kbd>o</kbd>: open file
<kbd>i</kbd>: add to .gitignore <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>: stash changes
<kbd>S</kbd>: view stash options <kbd>S</kbd>: view stash options
<kbd>a</kbd>: stage/unstage all <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>enter</kbd>: stage individual hunks/lines for file, or collapse/expand for directory
<kbd>f</kbd>: fetch <kbd>:</kbd>: execute custom command
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
<kbd>g</kbd>: view upstream reset options <kbd>g</kbd>: view upstream reset options
<kbd>`</kbd>: toggle file tree view <kbd>`</kbd>: toggle file tree view
<kbd>M</kbd>: open external merge tool (git mergetool) <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> </pre>
## Files Panel (Submodules) ## Files Panel (Submodules)

View File

@ -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>pgdown</kbd>: scroll naar beneden vanaf hoofdpaneel (fn+down)
<kbd>m</kbd>: bekijk merge/rebase opties <kbd>m</kbd>: bekijk merge/rebase opties
<kbd>ctrl+p</kbd>: bekijk aangepaste patch opties <kbd>ctrl+p</kbd>: bekijk aangepaste patch opties
<kbd>P</kbd>: push
<kbd>p</kbd>: pull
<kbd>R</kbd>: verversen <kbd>R</kbd>: verversen
<kbd>x</kbd>: open menu <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>: volgende scherm modus (normaal/half/groot)
<kbd>_</kbd>: vorige scherm modus <kbd>_</kbd>: vorige scherm modus
<kbd>:</kbd>: voer aangepaste commando uit <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>: open command log menu
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <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>{</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> </pre>
## Lijstpaneel Navigatie ## 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 <kbd>@</kbd>: open command log menu
</pre> </pre>
## Bestanden Paneel
<pre>
<kbd>ctrl+b</kbd>: Commit dossiers filteren
</pre>
## Bestanden Paneel (Bestanden) ## Bestanden Paneel (Bestanden)
<pre> <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>w</kbd>: commit veranderingen zonder pre-commit hook
<kbd>A</kbd>: wijzig laatste commit <kbd>A</kbd>: wijzig laatste commit
<kbd>C</kbd>: commit veranderingen met de git editor <kbd>C</kbd>: commit veranderingen met de git editor
<kbd>d</kbd>: bekijk 'veranderingen ongedaan maken' opties
<kbd>e</kbd>: verander bestand <kbd>e</kbd>: verander bestand
<kbd>o</kbd>: open bestand <kbd>o</kbd>: open bestand
<kbd>i</kbd>: voeg toe aan .gitignore <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>: stash-bestanden
<kbd>S</kbd>: bekijk stash opties <kbd>S</kbd>: bekijk stash opties
<kbd>a</kbd>: toggle staged alle <kbd>a</kbd>: toggle staged alle
<kbd>D</kbd>: bekijk reset opties
<kbd>enter</kbd>: stage individuele hunks/lijnen <kbd>enter</kbd>: stage individuele hunks/lijnen
<kbd>f</kbd>: fetch <kbd>:</kbd>: voor aangepaste commando uit
<kbd>ctrl+o</kbd>: kopieer de bestandsnaam naar het klembord
<kbd>g</kbd>: bekijk upstream reset opties <kbd>g</kbd>: bekijk upstream reset opties
<kbd>`</kbd>: toggle bestandsboom weergave <kbd>`</kbd>: toggle bestandsboom weergave
<kbd>M</kbd>: open external merge tool (git mergetool) <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> </pre>
## Bestanden Paneel (Submodules) ## Bestanden Paneel (Submodules)

View File

@ -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>pgdown</kbd>: scroll down main panel (fn+down)
<kbd>m</kbd>: widok scalenia/opcje zmiany bazy <kbd>m</kbd>: widok scalenia/opcje zmiany bazy
<kbd>ctrl+p</kbd>: view custom patch options <kbd>ctrl+p</kbd>: view custom patch options
<kbd>P</kbd>: push
<kbd>p</kbd>: pull
<kbd>R</kbd>: odśwież <kbd>R</kbd>: odśwież
<kbd>x</kbd>: open menu <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>: next screen mode (normal/half/fullscreen)
<kbd>_</kbd>: prev screen mode <kbd>_</kbd>: prev screen mode
<kbd>:</kbd>: wykonaj własną komendę
<kbd>ctrl+s</kbd>: view filter-by-path options <kbd>ctrl+s</kbd>: view filter-by-path options
<kbd>W</kbd>: open diff menu <kbd>W</kbd>: open diff menu
<kbd>ctrl+e</kbd>: open diff menu <kbd>ctrl+e</kbd>: open diff menu
<kbd>@</kbd>: open command log menu <kbd>@</kbd>: open command log menu
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <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>{</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> </pre>
## List Panel Navigation ## 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 <kbd>@</kbd>: open command log menu
</pre> </pre>
## Pliki Panel
<pre>
<kbd>ctrl+b</kbd>: Filtrowanie commitów
</pre>
## Pliki Panel (Pliki) ## Pliki Panel (Pliki)
<pre> <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>c</kbd>: Zatwierdź zmiany
<kbd>w</kbd>: zatwierdź zmiany bez skryptu pre-commit <kbd>w</kbd>: zatwierdź zmiany bez skryptu pre-commit
<kbd>A</kbd>: Zmień ostatni commit <kbd>A</kbd>: Zmień ostatni commit
<kbd>C</kbd>: Zatwierdź zmiany używając edytora <kbd>C</kbd>: Zatwierdź zmiany używając edytora
<kbd>d</kbd>: pokaż opcje porzucania zmian
<kbd>e</kbd>: edytuj plik <kbd>e</kbd>: edytuj plik
<kbd>o</kbd>: otwórz plik <kbd>o</kbd>: otwórz plik
<kbd>i</kbd>: dodaj do .gitignore <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>: przechowaj zmiany
<kbd>S</kbd>: wyświetl opcje schowka <kbd>S</kbd>: wyświetl opcje schowka
<kbd>a</kbd>: przełącz stan poczekalni wszystkich <kbd>a</kbd>: przełącz stan poczekalni wszystkich
<kbd>D</kbd>: wyświetl opcje resetu
<kbd>enter</kbd>: zatwierdź pojedyncze linie <kbd>enter</kbd>: zatwierdź pojedyncze linie
<kbd>f</kbd>: pobierz <kbd>:</kbd>: wykonaj własną komendę
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
<kbd>g</kbd>: view upstream reset options <kbd>g</kbd>: view upstream reset options
<kbd>`</kbd>: toggle file tree view <kbd>`</kbd>: toggle file tree view
<kbd>M</kbd>: open external merge tool (git mergetool) <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> </pre>
## Pliki Panel (Submodules) ## Pliki Panel (Submodules)

View File

@ -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>pgdown</kbd>: 向下滚动主面板 (fn+down)
<kbd>m</kbd>: 查看 合并/变基 选项 <kbd>m</kbd>: 查看 合并/变基 选项
<kbd>ctrl+p</kbd>: 查看自定义补丁选项 <kbd>ctrl+p</kbd>: 查看自定义补丁选项
<kbd>P</kbd>: 推送
<kbd>p</kbd>: 拉取
<kbd>R</kbd>: 刷新 <kbd>R</kbd>: 刷新
<kbd>x</kbd>: 打开菜单 <kbd>x</kbd>: 打开菜单
<kbd>z</kbd>: (通过 reflog)撤销「实验功能」
<kbd>ctrl+z</kbd>: (通过 reflog)重做「实验功能」
<kbd>+</kbd>: 下一屏模式(正常/半屏/全屏) <kbd>+</kbd>: 下一屏模式(正常/半屏/全屏)
<kbd>_</kbd>: 上一屏模式 <kbd>_</kbd>: 上一屏模式
<kbd>:</kbd>: 执行自定义命令
<kbd>ctrl+s</kbd>: 查看按路径过滤选项 <kbd>ctrl+s</kbd>: 查看按路径过滤选项
<kbd>W</kbd>: 打开 diff 菜单 <kbd>W</kbd>: 打开 diff 菜单
<kbd>ctrl+e</kbd>: 打开 diff 菜单 <kbd>ctrl+e</kbd>: 打开 diff 菜单
<kbd>@</kbd>: 打开命令日志菜单 <kbd>@</kbd>: 打开命令日志菜单
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view <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>{</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> </pre>
## 列表面板导航 ## 列表面板导航
@ -170,20 +169,20 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd>@</kbd>: 打开命令日志菜单 <kbd>@</kbd>: 打开命令日志菜单
</pre> </pre>
## 文件 面板
<pre>
<kbd>ctrl+b</kbd>: 过滤提交文件
</pre>
## 文件 面板 (文件) ## 文件 面板 (文件)
<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>c</kbd>: 提交更改
<kbd>w</kbd>: 提交更改而无需预先提交钩子 <kbd>w</kbd>: 提交更改而无需预先提交钩子
<kbd>A</kbd>: 修补最后一次提交 <kbd>A</kbd>: 修补最后一次提交
<kbd>C</kbd>: 提交更改(使用编辑器编辑提交信息) <kbd>C</kbd>: 提交更改(使用编辑器编辑提交信息)
<kbd>d</kbd>: 查看'放弃更改‘选项
<kbd>e</kbd>: 编辑文件 <kbd>e</kbd>: 编辑文件
<kbd>o</kbd>: 打开文件 <kbd>o</kbd>: 打开文件
<kbd>i</kbd>: 添加到 .gitignore <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>S</kbd>: 查看隐藏选项 <kbd>S</kbd>: 查看隐藏选项
<kbd>a</kbd>: 切换所有文件的暂存状态 <kbd>a</kbd>: 切换所有文件的暂存状态
<kbd>D</kbd>: 查看重置选项
<kbd>enter</kbd>: 暂存单个 块/行 用于文件, 或 折叠/展开 目录 <kbd>enter</kbd>: 暂存单个 块/行 用于文件, 或 折叠/展开 目录
<kbd>f</kbd>: 抓取 <kbd>:</kbd>: 执行自定义命令
<kbd>ctrl+o</kbd>: 将文件名复制到剪贴板
<kbd>g</kbd>: 查看上游重置选项 <kbd>g</kbd>: 查看上游重置选项
<kbd>`</kbd>: 切换文件树视图 <kbd>`</kbd>: 切换文件树视图
<kbd>M</kbd>: 打开合并工具 <kbd>M</kbd>: 打开合并工具
<kbd>ctrl+w</kbd>: 切换是否在差异视图中显示空白更改
<kbd>space</kbd>: 切换暂存状态
</pre> </pre>
## 文件 面板 (子模块) ## 文件 面板 (子模块)

2
go.mod
View File

@ -14,7 +14,6 @@ require (
github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 // indirect github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 // indirect
github.com/go-errors/errors v1.4.1 github.com/go-errors/errors v1.4.1
github.com/go-logfmt/logfmt v0.5.0 // indirect 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/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect github.com/google/go-cmp v0.5.6 // indirect
github.com/gookit/color v1.4.2 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/net v0.0.0-20201002202402-0a1ea396d57c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // 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 gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0
) )

3
go.sum
View File

@ -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/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 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= 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.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 h1:eoaSI4eEwM5eTx/HvmRSwmicxuMhL73AyoEfM1oCJLc=
github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b/go.mod h1:ZPwXnysybtQqdqKcWMWXux9aGdtMHe+kr+cwEZEe+A4= 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/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 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= 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.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 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

View File

@ -145,7 +145,7 @@ func (gui *Gui) contextTree() context.ContextTree {
}, },
Merging: &BasicContext{ Merging: &BasicContext{
OnFocus: OnFocusWrapper(func() error { return gui.renderConflictsWithLock(true) }), OnFocus: OnFocusWrapper(func() error { return gui.renderConflictsWithLock(true) }),
Kind: MAIN_CONTEXT, Kind: types.MAIN_CONTEXT,
ViewName: "main", ViewName: "main",
Key: MAIN_MERGING_CONTEXT_KEY, Key: MAIN_MERGING_CONTEXT_KEY,
OnGetOptionsMap: gui.getMergingOptions, OnGetOptionsMap: gui.getMergingOptions,

View File

@ -4,15 +4,16 @@ import (
"testing" "testing"
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestCanDeactivatePopupContextsWithoutViews(t *testing.T) { func TestCanDeactivatePopupContextsWithoutViews(t *testing.T) {
contexts := []func(gui *Gui) Context{ contexts := []func(gui *Gui) types.Context{
func(gui *Gui) Context { return gui.State.Contexts.Credentials }, func(gui *Gui) types.Context { return gui.State.Contexts.Credentials },
func(gui *Gui) Context { return gui.State.Contexts.Confirmation }, func(gui *Gui) types.Context { return gui.State.Contexts.Confirmation },
func(gui *Gui) Context { return gui.State.Contexts.CommitMessage }, func(gui *Gui) types.Context { return gui.State.Contexts.CommitMessage },
func(gui *Gui) Context { return gui.State.Contexts.Search }, func(gui *Gui) types.Context { return gui.State.Contexts.Search },
} }
for _, c := range contexts { for _, c := range contexts {

View File

@ -13,9 +13,9 @@ import (
) )
type BisectController struct { type BisectController struct {
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
git *commands.GitCommand git *commands.GitCommand
getSelectedLocalCommit func() *models.Commit getSelectedLocalCommit func() *models.Commit
getCommits func() []*models.Commit getCommits func() []*models.Commit
@ -25,16 +25,16 @@ var _ types.IController = &BisectController{}
func NewBisectController( func NewBisectController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
git *commands.GitCommand, git *commands.GitCommand,
getSelectedLocalCommit func() *models.Commit, getSelectedLocalCommit func() *models.Commit,
getCommits func() []*models.Commit, getCommits func() []*models.Commit,
) *BisectController { ) *BisectController {
return &BisectController{ return &BisectController{
c: c, c: c,
context: context, getContext: getContext,
git: git, git: git,
getSelectedLocalCommit: getSelectedLocalCommit, getSelectedLocalCommit: getSelectedLocalCommit,
getCommits: getCommits, getCommits: getCommits,
@ -249,8 +249,8 @@ func (self *BisectController) selectCurrentBisectCommit() {
// find index of commit with that sha, move cursor to that. // find index of commit with that sha, move cursor to that.
for i, commit := range self.getCommits() { for i, commit := range self.getCommits() {
if commit.Sha == info.GetCurrentSha() { if commit.Sha == info.GetCurrentSha() {
self.context.GetPanelState().SetSelectedLineIdx(i) self.getContext().GetPanelState().SetSelectedLineIdx(i)
_ = self.context.HandleFocus() _ = self.getContext().HandleFocus()
break break
} }
} }
@ -269,5 +269,5 @@ func (self *BisectController) checkSelected(callback func(*models.Commit) error)
} }
func (self *BisectController) Context() types.Context { func (self *BisectController) Context() types.Context {
return self.context return self.getContext()
} }

View File

@ -22,14 +22,14 @@ type FilesController struct {
// case I would actually prefer a _zero_ letter variable name in the form of // 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 // struct embedding, but Go does not allow hiding public fields in an embedded struct
// to the client // to the client
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
git *commands.GitCommand git *commands.GitCommand
os *oscommands.OSCommand os *oscommands.OSCommand
getSelectedFileNode func() *filetree.FileNode getSelectedFileNode func() *filetree.FileNode
allContexts context.ContextTree getContexts func() context.ContextTree
fileTreeViewModel *filetree.FileTreeViewModel getViewModel func() *filetree.FileTreeViewModel
enterSubmodule func(submodule *models.SubmoduleConfig) error enterSubmodule func(submodule *models.SubmoduleConfig) error
getSubmodules func() []*models.SubmoduleConfig getSubmodules func() []*models.SubmoduleConfig
setCommitMessage func(message string) setCommitMessage func(message string)
@ -49,12 +49,12 @@ var _ types.IController = &FilesController{}
func NewFilesController( func NewFilesController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
git *commands.GitCommand, git *commands.GitCommand,
os *oscommands.OSCommand, os *oscommands.OSCommand,
getSelectedFileNode func() *filetree.FileNode, getSelectedFileNode func() *filetree.FileNode,
allContexts context.ContextTree, allContexts func() context.ContextTree,
fileTreeViewModel *filetree.FileTreeViewModel, getViewModel func() *filetree.FileTreeViewModel,
enterSubmodule func(submodule *models.SubmoduleConfig) error, enterSubmodule func(submodule *models.SubmoduleConfig) error,
getSubmodules func() []*models.SubmoduleConfig, getSubmodules func() []*models.SubmoduleConfig,
setCommitMessage func(message string), setCommitMessage func(message string),
@ -70,12 +70,12 @@ func NewFilesController(
) *FilesController { ) *FilesController {
return &FilesController{ return &FilesController{
c: c, c: c,
context: context, getContext: getContext,
git: git, git: git,
os: os, os: os,
getSelectedFileNode: getSelectedFileNode, getSelectedFileNode: getSelectedFileNode,
allContexts: allContexts, getContexts: allContexts,
fileTreeViewModel: fileTreeViewModel, getViewModel: getViewModel,
enterSubmodule: enterSubmodule, enterSubmodule: enterSubmodule,
getSubmodules: getSubmodules, getSubmodules: getSubmodules,
setCommitMessage: setCommitMessage, setCommitMessage: setCommitMessage,
@ -100,7 +100,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co
}, },
{ {
Key: gocui.MouseLeft, 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 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), Key: getKey(config.Universal.Edit),
Handler: self.edit, Handler: self.checkSelectedFileNode(self.edit),
Description: self.c.Tr.LcEditFile, Description: self.c.Tr.LcEditFile,
}, },
{ {
@ -139,7 +139,7 @@ func (self *FilesController) Keybindings(getKey func(key string) interface{}, co
}, },
{ {
Key: getKey(config.Files.IgnoreFile), Key: getKey(config.Files.IgnoreFile),
Handler: self.ignore, Handler: self.checkSelectedFileNode(self.ignore),
Description: self.c.Tr.LcIgnoreFile, 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 { func (self *FilesController) press(node *filetree.FileNode) error {
@ -200,7 +200,7 @@ func (self *FilesController) press(node *filetree.FileNode) error {
file := node.File file := node.File
if file.HasInlineMergeConflicts { if file.HasInlineMergeConflicts {
return self.c.PushContext(self.allContexts.Merging) return self.c.PushContext(self.getContexts().Merging)
} }
if file.HasUnstagedChanges { if file.HasUnstagedChanges {
@ -239,7 +239,7 @@ func (self *FilesController) press(node *filetree.FileNode) error {
return err return err
} }
return self.context.HandleFocus() return self.getContext().HandleFocus()
} }
func (self *FilesController) checkSelectedFileNode(callback func(*filetree.FileNode) error) func() error { 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 { func (self *FilesController) Context() types.Context {
return self.context return self.getContext()
} }
func (self *FilesController) getSelectedFile() *models.File { 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.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 { func (self *FilesController) allFilesStaged() bool {
for _, file := range self.fileTreeViewModel.GetAllFiles() { for _, file := range self.getViewModel().GetAllFiles() {
if file.HasUnstagedChanges { if file.HasUnstagedChanges {
return false return false
} }
@ -334,15 +323,10 @@ func (self *FilesController) stageAll() error {
return err return err
} }
return self.allContexts.Files.HandleFocus() return self.getContexts().Files.HandleFocus()
} }
func (self *FilesController) ignore() error { func (self *FilesController) ignore(node *filetree.FileNode) error {
node := self.getSelectedFileNode()
if node == nil {
return nil
}
if node.GetPath() == ".gitignore" { if node.GetPath() == ".gitignore" {
return self.c.ErrorMsg("Cannot ignore .gitignore") return self.c.ErrorMsg("Cannot ignore .gitignore")
} }
@ -444,7 +428,7 @@ func (self *FilesController) HandleCommitPress() error {
return self.c.Error(err) return self.c.Error(err)
} }
if self.fileTreeViewModel.GetItemsLength() == 0 { if self.getViewModel().GetItemsLength() == 0 {
return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) 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.PushContext(self.getContexts().CommitMessage); err != nil {
return err return err
} }
@ -495,7 +479,7 @@ func (self *FilesController) promptToStageAllAndRetry(retry func() error) error
} }
func (self *FilesController) handleAmendCommitPress() error { func (self *FilesController) handleAmendCommitPress() error {
if self.fileTreeViewModel.GetItemsLength() == 0 { if self.getViewModel().GetItemsLength() == 0 {
return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle)
} }
@ -521,7 +505,7 @@ func (self *FilesController) handleAmendCommitPress() error {
// HandleCommitEditorPress - handle when the user wants to commit changes via // HandleCommitEditorPress - handle when the user wants to commit changes via
// their editor rather than via the popup panel // their editor rather than via the popup panel
func (self *FilesController) HandleCommitEditorPress() error { func (self *FilesController) HandleCommitEditorPress() error {
if self.fileTreeViewModel.GetItemsLength() == 0 { if self.getViewModel().GetItemsLength() == 0 {
return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle)
} }
@ -562,16 +546,11 @@ func (self *FilesController) handleStatusFilterPressed() error {
} }
func (self *FilesController) setStatusFiltering(filter filetree.FileTreeDisplayFilter) error { func (self *FilesController) setStatusFiltering(filter filetree.FileTreeDisplayFilter) error {
self.fileTreeViewModel.SetFilter(filter) self.getViewModel().SetFilter(filter)
return self.c.PostRefreshUpdate(self.context) return self.c.PostRefreshUpdate(self.getContext())
} }
func (self *FilesController) edit() error { func (self *FilesController) edit(node *filetree.FileNode) error {
node := self.getSelectedFileNode()
if node == nil {
return nil
}
if node.File == nil { if node.File == nil {
return self.c.ErrorMsg(self.c.Tr.ErrCannotEditDirectory) return self.c.ErrorMsg(self.c.Tr.ErrCannotEditDirectory)
} }
@ -594,7 +573,7 @@ func (self *FilesController) switchToMerge() error {
return nil return nil
} }
self.switchToMergeFn(path) return self.switchToMergeFn(file.Name)
} }
func (self *FilesController) handleCustomCommand() error { func (self *FilesController) handleCustomCommand() error {
@ -658,9 +637,9 @@ func (self *FilesController) handleToggleDirCollapsed() error {
return nil return nil
} }
self.fileTreeViewModel.ToggleCollapsed(node.GetPath()) self.getViewModel().ToggleCollapsed(node.GetPath())
if err := self.c.PostRefreshUpdate(self.allContexts.Files); err != nil { if err := self.c.PostRefreshUpdate(self.getContexts().Files); err != nil {
self.c.Log.Error(err) self.c.Log.Error(err)
} }
@ -671,18 +650,18 @@ func (self *FilesController) toggleTreeView() error {
// get path of currently selected file // get path of currently selected file
path := self.getSelectedPath() path := self.getSelectedPath()
self.fileTreeViewModel.ToggleShowTree() self.getViewModel().ToggleShowTree()
// find that same node in the new format and move the cursor to it // find that same node in the new format and move the cursor to it
if path != "" { if path != "" {
self.fileTreeViewModel.ExpandToPath(path) self.getViewModel().ExpandToPath(path)
index, found := self.fileTreeViewModel.GetIndexForPath(path) index, found := self.getViewModel().GetIndexForPath(path)
if found { if found {
self.context.GetPanelState().SetSelectedLineIdx(index) self.getContext().GetPanelState().SetSelectedLineIdx(index)
} }
} }
return self.c.PostRefreshUpdate(self.context) return self.c.PostRefreshUpdate(self.getContext())
} }
func (self *FilesController) OpenMergeTool() error { func (self *FilesController) OpenMergeTool() error {

View File

@ -26,11 +26,11 @@ type (
) )
type LocalCommitsController struct { type LocalCommitsController struct {
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
os *oscommands.OSCommand os *oscommands.OSCommand
git *commands.GitCommand git *commands.GitCommand
refHelper IRefHelper refHelper IRefHelper
getSelectedLocalCommit func() *models.Commit getSelectedLocalCommit func() *models.Commit
getCommits func() []*models.Commit getCommits func() []*models.Commit
@ -51,7 +51,7 @@ var _ types.IController = &LocalCommitsController{}
func NewLocalCommitsController( func NewLocalCommitsController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
os *oscommands.OSCommand, os *oscommands.OSCommand,
git *commands.GitCommand, git *commands.GitCommand,
refHelper IRefHelper, refHelper IRefHelper,
@ -71,7 +71,7 @@ func NewLocalCommitsController(
) *LocalCommitsController { ) *LocalCommitsController {
return &LocalCommitsController{ return &LocalCommitsController{
c: c, c: c,
context: context, getContext: getContext,
os: os, os: os,
git: git, git: git,
refHelper: refHelper, refHelper: refHelper,
@ -178,7 +178,7 @@ func (self *LocalCommitsController) Keybindings(
}, },
{ {
Key: gocui.MouseLeft, Key: gocui.MouseLeft,
Handler: func() error { return self.context.HandleClick(self.checkSelected(self.enter)) }, Handler: func() error { return self.getContext().HandleClick(self.checkSelected(self.enter)) },
}, },
} }
@ -225,7 +225,7 @@ func (self *LocalCommitsController) Keybindings(
}, },
}...) }...)
return append(bindings, self.context.Keybindings(getKey, config, guards)...) return append(bindings, self.getContext().Keybindings(getKey, config, guards)...)
} }
func (self *LocalCommitsController) squashDown() error { func (self *LocalCommitsController) squashDown() error {
@ -420,7 +420,7 @@ func (self *LocalCommitsController) handleMidRebaseCommand(action string) (bool,
} }
func (self *LocalCommitsController) handleCommitMoveDown() error { func (self *LocalCommitsController) handleCommitMoveDown() error {
index := self.context.GetPanelState().GetSelectedLineIdx() index := self.getContext().GetPanelState().GetSelectedLineIdx()
commits := self.getCommits() commits := self.getCommits()
selectedCommit := self.getCommits()[index] selectedCommit := self.getCommits()[index]
if selectedCommit.Status == "rebasing" { if selectedCommit.Status == "rebasing" {
@ -436,7 +436,7 @@ func (self *LocalCommitsController) handleCommitMoveDown() error {
if err := self.git.Rebase.MoveTodoDown(index); err != nil { if err := self.git.Rebase.MoveTodoDown(index); err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
self.context.HandleNextLine() _ = self.getContext().HandleNextLine()
return self.c.Refresh(types.RefreshOptions{ return self.c.Refresh(types.RefreshOptions{
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS}, Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
}) })
@ -446,14 +446,14 @@ func (self *LocalCommitsController) handleCommitMoveDown() error {
self.c.LogAction(self.c.Tr.Actions.MoveCommitDown) self.c.LogAction(self.c.Tr.Actions.MoveCommitDown)
err := self.git.Rebase.MoveCommitDown(self.getCommits(), index) err := self.git.Rebase.MoveCommitDown(self.getCommits(), index)
if err == nil { if err == nil {
self.context.HandleNextLine() _ = self.getContext().HandleNextLine()
} }
return self.checkMergeOrRebase(err) return self.checkMergeOrRebase(err)
}) })
} }
func (self *LocalCommitsController) handleCommitMoveUp() error { func (self *LocalCommitsController) handleCommitMoveUp() error {
index := self.context.GetPanelState().GetSelectedLineIdx() index := self.getContext().GetPanelState().GetSelectedLineIdx()
if index == 0 { if index == 0 {
return nil return nil
} }
@ -471,7 +471,7 @@ func (self *LocalCommitsController) handleCommitMoveUp() error {
if err := self.git.Rebase.MoveTodoDown(index - 1); err != nil { if err := self.git.Rebase.MoveTodoDown(index - 1); err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
self.context.HandlePrevLine() _ = self.getContext().HandlePrevLine()
return self.c.Refresh(types.RefreshOptions{ return self.c.Refresh(types.RefreshOptions{
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS}, Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
}) })
@ -481,7 +481,7 @@ func (self *LocalCommitsController) handleCommitMoveUp() error {
self.c.LogAction(self.c.Tr.Actions.MoveCommitUp) self.c.LogAction(self.c.Tr.Actions.MoveCommitUp)
err := self.git.Rebase.MoveCommitDown(self.getCommits(), index-1) err := self.git.Rebase.MoveCommitDown(self.getCommits(), index-1)
if err == nil { if err == nil {
self.context.HandlePrevLine() _ = self.getContext().HandlePrevLine()
} }
return self.checkMergeOrRebase(err) return self.checkMergeOrRebase(err)
}) })
@ -549,7 +549,7 @@ func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.C
} }
func (self *LocalCommitsController) afterRevertCommit() error { func (self *LocalCommitsController) afterRevertCommit() error {
self.context.HandleNextLine() _ = self.getContext().HandleNextLine()
return self.c.Refresh(types.RefreshOptions{ return self.c.Refresh(types.RefreshOptions{
Mode: types.BLOCK_UI, Scope: []types.RefreshableView{types.COMMITS, types.BRANCHES}, Mode: types.BLOCK_UI, Scope: []types.RefreshableView{types.COMMITS, types.BRANCHES},
}) })
@ -559,7 +559,7 @@ func (self *LocalCommitsController) enter(commit *models.Commit) error {
return self.switchToCommitFilesContext(SwitchToCommitFilesContextOpts{ return self.switchToCommitFilesContext(SwitchToCommitFilesContextOpts{
RefName: commit.Sha, RefName: commit.Sha,
CanRebase: true, CanRebase: true,
Context: self.context, Context: self.getContext(),
WindowName: "commits", WindowName: "commits",
}) })
} }
@ -647,7 +647,7 @@ func (self *LocalCommitsController) gotoBottom() error {
} }
} }
self.context.HandleGotoBottom() _ = self.getContext().HandleGotoBottom()
return nil return nil
} }
@ -779,5 +779,5 @@ func (self *LocalCommitsController) checkSelected(callback func(*models.Commit)
} }
func (self *LocalCommitsController) Context() types.Context { func (self *LocalCommitsController) Context() types.Context {
return self.context return self.getContext()
} }

View File

@ -8,8 +8,8 @@ import (
) )
type MenuController struct { type MenuController struct {
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
getSelectedMenuItem func() *popup.MenuItem getSelectedMenuItem func() *popup.MenuItem
} }
@ -18,12 +18,12 @@ var _ types.IController = &MenuController{}
func NewMenuController( func NewMenuController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
getSelectedMenuItem func() *popup.MenuItem, getSelectedMenuItem func() *popup.MenuItem,
) *MenuController { ) *MenuController {
return &MenuController{ return &MenuController{
c: c, c: c,
context: context, getContext: getContext,
getSelectedMenuItem: getSelectedMenuItem, getSelectedMenuItem: getSelectedMenuItem,
} }
} }
@ -44,11 +44,11 @@ func (self *MenuController) Keybindings(getKey func(key string) interface{}, con
}, },
{ {
Key: gocui.MouseLeft, Key: gocui.MouseLeft,
Handler: func() error { return self.context.HandleClick(self.press) }, Handler: func() error { return self.getContext().HandleClick(self.press) },
}, },
} }
return append(bindings, self.context.Keybindings(getKey, config, guards)...) return append(bindings, self.getContext().Keybindings(getKey, config, guards)...)
} }
func (self *MenuController) press() error { func (self *MenuController) press() error {
@ -66,5 +66,5 @@ func (self *MenuController) press() error {
} }
func (self *MenuController) Context() types.Context { func (self *MenuController) Context() types.Context {
return self.context return self.getContext()
} }

View File

@ -14,13 +14,13 @@ import (
) )
type RemotesController struct { type RemotesController struct {
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
git *commands.GitCommand git *commands.GitCommand
getSelectedRemote func() *models.Remote getSelectedRemote func() *models.Remote
setRemoteBranches func([]*models.RemoteBranch) setRemoteBranches func([]*models.RemoteBranch)
allContexts context.ContextTree getContexts func() context.ContextTree
fetchMutex *sync.Mutex fetchMutex *sync.Mutex
} }
@ -28,9 +28,9 @@ var _ types.IController = &RemotesController{}
func NewRemotesController( func NewRemotesController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
git *commands.GitCommand, git *commands.GitCommand,
allContexts context.ContextTree, getContexts func() context.ContextTree,
getSelectedRemote func() *models.Remote, getSelectedRemote func() *models.Remote,
setRemoteBranches func([]*models.RemoteBranch), setRemoteBranches func([]*models.RemoteBranch),
fetchMutex *sync.Mutex, fetchMutex *sync.Mutex,
@ -38,8 +38,8 @@ func NewRemotesController(
return &RemotesController{ return &RemotesController{
c: c, c: c,
git: git, git: git,
allContexts: allContexts, getContexts: getContexts,
context: context, getContext: getContext,
getSelectedRemote: getSelectedRemote, getSelectedRemote: getSelectedRemote,
setRemoteBranches: setRemoteBranches, setRemoteBranches: setRemoteBranches,
fetchMutex: fetchMutex, fetchMutex: fetchMutex,
@ -54,7 +54,7 @@ func (self *RemotesController) Keybindings(getKey func(key string) interface{},
}, },
{ {
Key: gocui.MouseLeft, Key: gocui.MouseLeft,
Handler: func() error { return self.context.HandleClick(self.checkSelected(self.enter)) }, Handler: func() error { return self.getContext().HandleClick(self.checkSelected(self.enter)) },
}, },
{ {
Key: getKey(config.Branches.FetchRemote), Key: getKey(config.Branches.FetchRemote),
@ -78,7 +78,7 @@ func (self *RemotesController) Keybindings(getKey func(key string) interface{},
}, },
} }
return append(bindings, self.context.Keybindings(getKey, config, guards)...) return append(bindings, self.getContext().Keybindings(getKey, config, guards)...)
} }
func (self *RemotesController) enter(remote *models.Remote) error { func (self *RemotesController) enter(remote *models.Remote) error {
@ -89,9 +89,9 @@ func (self *RemotesController) enter(remote *models.Remote) error {
if len(remote.Branches) == 0 { if len(remote.Branches) == 0 {
newSelectedLine = -1 newSelectedLine = -1
} }
self.allContexts.RemoteBranches.GetPanelState().SetSelectedLineIdx(newSelectedLine) self.getContexts().RemoteBranches.GetPanelState().SetSelectedLineIdx(newSelectedLine)
return self.c.PushContext(self.allContexts.RemoteBranches) return self.c.PushContext(self.getContexts().RemoteBranches)
} }
func (self *RemotesController) add() error { func (self *RemotesController) add() error {
@ -200,5 +200,5 @@ func (self *RemotesController) checkSelected(callback func(*models.Remote) error
} }
func (self *RemotesController) Context() types.Context { func (self *RemotesController) Context() types.Context {
return self.context return self.getContext()
} }

View File

@ -12,9 +12,9 @@ import (
type TagsController struct { type TagsController struct {
c *ControllerCommon c *ControllerCommon
context types.IListContext getContext func() types.IListContext
git *commands.GitCommand git *commands.GitCommand
allContexts context.ContextTree getContexts func() context.ContextTree
refHelper IRefHelper refHelper IRefHelper
suggestionsHelper ISuggestionsHelper suggestionsHelper ISuggestionsHelper
@ -27,9 +27,9 @@ var _ types.IController = &TagsController{}
func NewTagsController( func NewTagsController(
c *ControllerCommon, c *ControllerCommon,
context types.IListContext, getContext func() types.IListContext,
git *commands.GitCommand, git *commands.GitCommand,
allContexts context.ContextTree, getContexts func() context.ContextTree,
refHelper IRefHelper, refHelper IRefHelper,
suggestionsHelper ISuggestionsHelper, suggestionsHelper ISuggestionsHelper,
@ -38,9 +38,9 @@ func NewTagsController(
) *TagsController { ) *TagsController {
return &TagsController{ return &TagsController{
c: c, c: c,
context: context, getContext: getContext,
git: git, git: git,
allContexts: allContexts, getContexts: getContexts,
refHelper: refHelper, refHelper: refHelper,
suggestionsHelper: suggestionsHelper, suggestionsHelper: suggestionsHelper,
@ -84,7 +84,7 @@ func (self *TagsController) Keybindings(getKey func(key string) interface{}, con
}, },
} }
return append(bindings, self.context.Keybindings(getKey, config, guards)...) return append(bindings, self.getContext().Keybindings(getKey, config, guards)...)
} }
func (self *TagsController) checkout(tag *models.Tag) error { func (self *TagsController) checkout(tag *models.Tag) error {
@ -92,7 +92,7 @@ func (self *TagsController) checkout(tag *models.Tag) error {
if err := self.refHelper.CheckoutRef(tag.Name, types.CheckoutRefOptions{}); err != nil { if err := self.refHelper.CheckoutRef(tag.Name, types.CheckoutRefOptions{}); err != nil {
return err return err
} }
return self.c.PushContext(self.allContexts.Branches) return self.c.PushContext(self.getContexts().Branches)
} }
func (self *TagsController) enter(tag *models.Tag) error { func (self *TagsController) enter(tag *models.Tag) error {
@ -171,7 +171,7 @@ func (self *TagsController) CreateTagMenu(commitSha string) error {
} }
func (self *TagsController) afterTagCreate() error { func (self *TagsController) afterTagCreate() error {
self.context.GetPanelState().SetSelectedLineIdx(0) self.getContext().GetPanelState().SetSelectedLineIdx(0)
return self.c.Refresh(types.RefreshOptions{ return self.c.Refresh(types.RefreshOptions{
Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS, types.TAGS}, Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS, types.TAGS},
}) })
@ -225,5 +225,5 @@ func (self *TagsController) withSelectedTag(f func(tag *models.Tag) error) func(
} }
func (self *TagsController) Context() types.Context { func (self *TagsController) Context() types.Context {
return self.context return self.getContext()
} }

View File

@ -1,191 +1,182 @@
package gui package gui
import ( // const diffForTest = `diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go
"testing" // index 0da0a982..742b7dcf 100644
// --- a/pkg/gui/diff_context_size.go
// +++ b/pkg/gui/diff_context_size.go
// @@ -9,12 +9,12 @@ func getRefreshFunction(gui *Gui) func()error {
// }
// } else if key == MAIN_STAGING_CONTEXT_KEY {
// return func() error {
// - selectedLine := gui.Views.Secondary.SelectedLineIdx()
// + selectedLine := gui.State.Panels.LineByLine.GetSelectedLineIdx()
// return gui.handleRefreshStagingPanel(false, selectedLine)
// }
// } else if key == MAIN_PATCH_BUILDING_CONTEXT_KEY {
// `
"github.com/jesseduffield/gocui" // func setupGuiForTest(gui *Gui) {
"github.com/jesseduffield/lazygit/pkg/commands/patch" // gui.g = &gocui.Gui{}
"github.com/jesseduffield/lazygit/pkg/gui/popup" // gui.Views.Main, _ = gui.prepareView("main")
"github.com/stretchr/testify/assert" // gui.Views.Secondary, _ = gui.prepareView("secondary")
) // gui.Views.Options, _ = gui.prepareView("options")
// gui.git.Patch.PatchManager = &patch.PatchManager{}
// _, _ = gui.refreshLineByLinePanel(diffForTest, "", false, 11)
// }
const diffForTest = `diff --git a/pkg/gui/diff_context_size.go b/pkg/gui/diff_context_size.go // func TestIncreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) {
index 0da0a982..742b7dcf 100644 // contexts := []func(gui *Gui) types.Context{
--- a/pkg/gui/diff_context_size.go // func(gui *Gui) types.Context { return gui.State.Contexts.Files },
+++ b/pkg/gui/diff_context_size.go // func(gui *Gui) types.Context { return gui.State.Contexts.BranchCommits },
@@ -9,12 +9,12 @@ func getRefreshFunction(gui *Gui) func()error { // func(gui *Gui) types.Context { return gui.State.Contexts.CommitFiles },
} // func(gui *Gui) types.Context { return gui.State.Contexts.Stash },
} else if key == MAIN_STAGING_CONTEXT_KEY { // func(gui *Gui) types.Context { return gui.State.Contexts.Staging },
return func() error { // func(gui *Gui) types.Context { return gui.State.Contexts.PatchBuilding },
- selectedLine := gui.Views.Secondary.SelectedLineIdx() // func(gui *Gui) types.Context { return gui.State.Contexts.SubCommits },
+ selectedLine := gui.State.Panels.LineByLine.GetSelectedLineIdx() // }
return gui.handleRefreshStagingPanel(false, selectedLine)
}
} else if key == MAIN_PATCH_BUILDING_CONTEXT_KEY {
`
func setupGuiForTest(gui *Gui) { // for _, c := range contexts {
gui.g = &gocui.Gui{} // gui := NewDummyGui()
gui.Views.Main, _ = gui.prepareView("main") // context := c(gui)
gui.Views.Secondary, _ = gui.prepareView("secondary") // setupGuiForTest(gui)
gui.Views.Options, _ = gui.prepareView("options") // gui.c.UserConfig.Git.DiffContextSize = 1
gui.git.Patch.PatchManager = &patch.PatchManager{} // _ = gui.c.PushContext(context)
_, _ = gui.refreshLineByLinePanel(diffForTest, "", false, 11)
}
func TestIncreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) { // _ = gui.IncreaseContextInDiffView()
contexts := []func(gui *Gui) Context{
func(gui *Gui) Context { return gui.State.Contexts.Files },
func(gui *Gui) Context { return gui.State.Contexts.BranchCommits },
func(gui *Gui) Context { return gui.State.Contexts.CommitFiles },
func(gui *Gui) Context { return gui.State.Contexts.Stash },
func(gui *Gui) Context { return gui.State.Contexts.Staging },
func(gui *Gui) Context { return gui.State.Contexts.PatchBuilding },
func(gui *Gui) Context { return gui.State.Contexts.SubCommits },
}
for _, c := range contexts { // assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey()))
gui := NewDummyGui() // }
context := c(gui) // }
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 1
_ = gui.c.PushContext(context)
_ = gui.IncreaseContextInDiffView() // func TestDoesntIncreaseContextInDiffViewInContextWithoutDiff(t *testing.T) {
// contexts := []func(gui *Gui) types.Context{
// func(gui *Gui) types.Context { return gui.State.Contexts.Status },
// func(gui *Gui) types.Context { return gui.State.Contexts.Submodules },
// func(gui *Gui) types.Context { return gui.State.Contexts.Remotes },
// func(gui *Gui) types.Context { return gui.State.Contexts.Normal },
// func(gui *Gui) types.Context { return gui.State.Contexts.ReflogCommits },
// func(gui *Gui) types.Context { return gui.State.Contexts.RemoteBranches },
// func(gui *Gui) types.Context { return gui.State.Contexts.Tags },
// // not testing this because it will kick straight back to the files context
// // upon pushing the context
// // func(gui *Gui) types.Context { return gui.State.Contexts.Merging },
// func(gui *Gui) types.Context { return gui.State.Contexts.CommandLog },
// }
assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey())) // for _, c := range contexts {
} // gui := NewDummyGui()
} // context := c(gui)
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 1
// _ = gui.c.PushContext(context)
func TestDoesntIncreaseContextInDiffViewInContextWithoutDiff(t *testing.T) { // _ = gui.IncreaseContextInDiffView()
contexts := []func(gui *Gui) Context{
func(gui *Gui) Context { return gui.State.Contexts.Status },
func(gui *Gui) Context { return gui.State.Contexts.Submodules },
func(gui *Gui) Context { return gui.State.Contexts.Remotes },
func(gui *Gui) Context { return gui.State.Contexts.Normal },
func(gui *Gui) Context { return gui.State.Contexts.ReflogCommits },
func(gui *Gui) Context { return gui.State.Contexts.RemoteBranches },
func(gui *Gui) Context { return gui.State.Contexts.Tags },
// not testing this because it will kick straight back to the files context
// upon pushing the context
// func(gui *Gui) Context { return gui.State.Contexts.Merging },
func(gui *Gui) Context { return gui.State.Contexts.CommandLog },
}
for _, c := range contexts { // assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey()))
gui := NewDummyGui() // }
context := c(gui) // }
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 1
_ = gui.c.PushContext(context)
_ = gui.IncreaseContextInDiffView() // func TestDecreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) {
// contexts := []func(gui *Gui) types.Context{
// func(gui *Gui) types.Context { return gui.State.Contexts.Files },
// func(gui *Gui) types.Context { return gui.State.Contexts.BranchCommits },
// func(gui *Gui) types.Context { return gui.State.Contexts.CommitFiles },
// func(gui *Gui) types.Context { return gui.State.Contexts.Stash },
// func(gui *Gui) types.Context { return gui.State.Contexts.Staging },
// func(gui *Gui) types.Context { return gui.State.Contexts.PatchBuilding },
// func(gui *Gui) types.Context { return gui.State.Contexts.SubCommits },
// }
assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey())) // for _, c := range contexts {
} // gui := NewDummyGui()
} // context := c(gui)
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 2
// _ = gui.c.PushContext(context)
func TestDecreasesContextInDiffViewByOneInContextWithDiff(t *testing.T) { // _ = gui.DecreaseContextInDiffView()
contexts := []func(gui *Gui) Context{
func(gui *Gui) Context { return gui.State.Contexts.Files },
func(gui *Gui) Context { return gui.State.Contexts.BranchCommits },
func(gui *Gui) Context { return gui.State.Contexts.CommitFiles },
func(gui *Gui) Context { return gui.State.Contexts.Stash },
func(gui *Gui) Context { return gui.State.Contexts.Staging },
func(gui *Gui) Context { return gui.State.Contexts.PatchBuilding },
func(gui *Gui) Context { return gui.State.Contexts.SubCommits },
}
for _, c := range contexts { // assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey()))
gui := NewDummyGui() // }
context := c(gui) // }
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 2
_ = gui.c.PushContext(context)
_ = gui.DecreaseContextInDiffView() // func TestDoesntDecreaseContextInDiffViewInContextWithoutDiff(t *testing.T) {
// contexts := []func(gui *Gui) types.Context{
// func(gui *Gui) types.Context { return gui.State.Contexts.Status },
// func(gui *Gui) types.Context { return gui.State.Contexts.Submodules },
// func(gui *Gui) types.Context { return gui.State.Contexts.Remotes },
// func(gui *Gui) types.Context { return gui.State.Contexts.Normal },
// func(gui *Gui) types.Context { return gui.State.Contexts.ReflogCommits },
// func(gui *Gui) types.Context { return gui.State.Contexts.RemoteBranches },
// func(gui *Gui) types.Context { return gui.State.Contexts.Tags },
// // not testing this because it will kick straight back to the files context
// // upon pushing the context
// // func(gui *Gui) types.Context { return gui.State.Contexts.Merging },
// func(gui *Gui) types.Context { return gui.State.Contexts.CommandLog },
// }
assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey())) // for _, c := range contexts {
} // gui := NewDummyGui()
} // context := c(gui)
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 2
// _ = gui.c.PushContext(context)
func TestDoesntDecreaseContextInDiffViewInContextWithoutDiff(t *testing.T) { // _ = gui.DecreaseContextInDiffView()
contexts := []func(gui *Gui) Context{
func(gui *Gui) Context { return gui.State.Contexts.Status },
func(gui *Gui) Context { return gui.State.Contexts.Submodules },
func(gui *Gui) Context { return gui.State.Contexts.Remotes },
func(gui *Gui) Context { return gui.State.Contexts.Normal },
func(gui *Gui) Context { return gui.State.Contexts.ReflogCommits },
func(gui *Gui) Context { return gui.State.Contexts.RemoteBranches },
func(gui *Gui) Context { return gui.State.Contexts.Tags },
// not testing this because it will kick straight back to the files context
// upon pushing the context
// func(gui *Gui) Context { return gui.State.Contexts.Merging },
func(gui *Gui) Context { return gui.State.Contexts.CommandLog },
}
for _, c := range contexts { // assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey()))
gui := NewDummyGui() // }
context := c(gui) // }
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 2
_ = gui.c.PushContext(context)
_ = gui.DecreaseContextInDiffView() // func TestDoesntIncreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) {
// gui := NewDummyGui()
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 2
// _ = gui.c.PushContext(gui.State.Contexts.CommitFiles)
// gui.git.Patch.PatchManager.Start("from", "to", false, false)
assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize, string(context.GetKey())) // errorCount := 0
} // gui.PopupHandler = &popup.TestPopupHandler{
} // OnErrorMsg: func(message string) error {
// assert.Equal(t, gui.c.Tr.CantChangeContextSizeError, message)
// errorCount += 1
// return nil
// },
// }
func TestDoesntIncreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) { // _ = gui.IncreaseContextInDiffView()
gui := NewDummyGui()
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 2
_ = gui.c.PushContext(gui.State.Contexts.CommitFiles)
gui.git.Patch.PatchManager.Start("from", "to", false, false)
errorCount := 0 // assert.Equal(t, 1, errorCount)
gui.PopupHandler = &popup.TestPopupHandler{ // assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize)
OnErrorMsg: func(message string) error { // }
assert.Equal(t, gui.c.Tr.CantChangeContextSizeError, message)
errorCount += 1
return nil
},
}
_ = gui.IncreaseContextInDiffView() // func TestDoesntDecreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) {
// gui := NewDummyGui()
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 2
// _ = gui.c.PushContext(gui.State.Contexts.CommitFiles)
// gui.git.Patch.PatchManager.Start("from", "to", false, false)
assert.Equal(t, 1, errorCount) // errorCount := 0
assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize) // gui.PopupHandler = &popup.TestPopupHandler{
} // OnErrorMsg: func(message string) error {
// assert.Equal(t, gui.c.Tr.CantChangeContextSizeError, message)
// errorCount += 1
// return nil
// },
// }
func TestDoesntDecreaseContextInDiffViewInContextWhenInPatchBuildingMode(t *testing.T) { // _ = gui.DecreaseContextInDiffView()
gui := NewDummyGui()
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 2
_ = gui.c.PushContext(gui.State.Contexts.CommitFiles)
gui.git.Patch.PatchManager.Start("from", "to", false, false)
errorCount := 0 // assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize)
gui.PopupHandler = &popup.TestPopupHandler{ // }
OnErrorMsg: func(message string) error {
assert.Equal(t, gui.c.Tr.CantChangeContextSizeError, message)
errorCount += 1
return nil
},
}
_ = gui.DecreaseContextInDiffView() // func TestDecreasesContextInDiffViewNoFurtherThanOne(t *testing.T) {
// gui := NewDummyGui()
// setupGuiForTest(gui)
// gui.c.UserConfig.Git.DiffContextSize = 1
assert.Equal(t, 2, gui.c.UserConfig.Git.DiffContextSize) // _ = gui.DecreaseContextInDiffView()
}
func TestDecreasesContextInDiffViewNoFurtherThanOne(t *testing.T) { // assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize)
gui := NewDummyGui() // }
setupGuiForTest(gui)
gui.c.UserConfig.Git.DiffContextSize = 1
_ = gui.DecreaseContextInDiffView()
assert.Equal(t, 1, gui.c.UserConfig.Git.DiffContextSize)
}

View File

@ -301,23 +301,13 @@ func (gui *Gui) findNewSelectedIdx(prevNodes []*filetree.FileNode, currNodes []*
func (gui *Gui) onFocusFile() error { func (gui *Gui) onFocusFile() error {
gui.takeOverMergeConflictScrolling() gui.takeOverMergeConflictScrolling()
return nil
if gui.State.Panels.Merging.GetPath() != file.Name {
hasConflicts, err := gui.setMergeStateWithLock(file.Name)
if err != nil {
return err
}
if !hasConflicts {
return nil
}
}
// TODO: this can't be right.
return gui.pushContext(gui.State.Contexts.Merging)
} }
func (gui *Gui) getSetTextareaTextFn(view *gocui.View) func(string) { func (gui *Gui) getSetTextareaTextFn(getView func() *gocui.View) func(string) {
return func(text string) { return func(text string) {
// using a getView function so that we don't need to worry about when the view is created
view := getView()
view.ClearTextArea() view.ClearTextArea()
view.TextArea.TypeString(text) view.TextArea.TypeString(text)
view.RenderTextArea() view.RenderTextArea()

View File

@ -564,24 +564,34 @@ func NewGui(
gui.c = controllerCommon gui.c = controllerCommon
gui.resetState(filterPath, false) gui.resetState(filterPath, false)
gui.setControllers()
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors) presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
return gui, nil
}
func (gui *Gui) setControllers() {
controllerCommon := gui.c
osCommand := gui.OSCommand
getState := func() *GuiRepoState { return gui.State }
getContexts := func() context.ContextTree { return gui.State.Contexts }
// TODO: have a getGit function too
refHelper := NewRefHelper( refHelper := NewRefHelper(
controllerCommon, controllerCommon,
gui.git, gui.git,
gui.State, getState,
) )
gui.refHelper = refHelper gui.refHelper = refHelper
gui.suggestionsHelper = NewSuggestionsHelper(controllerCommon, gui.State, gui.refreshSuggestions) gui.suggestionsHelper = NewSuggestionsHelper(controllerCommon, getState, gui.refreshSuggestions)
gui.fileHelper = NewFileHelper(controllerCommon, gui.git, osCommand) gui.fileHelper = NewFileHelper(controllerCommon, gui.git, osCommand)
gui.workingTreeHelper = NewWorkingTreeHelper(gui.State.FileTreeViewModel) gui.workingTreeHelper = NewWorkingTreeHelper(func() *filetree.FileTreeViewModel { return gui.State.FileTreeViewModel })
tagsController := controllers.NewTagsController( tagsController := controllers.NewTagsController(
controllerCommon, controllerCommon,
gui.State.Contexts.Tags, func() types.IListContext { return gui.State.Contexts.Tags },
gui.git, gui.git,
gui.State.Contexts, getContexts,
refHelper, refHelper,
gui.suggestionsHelper, gui.suggestionsHelper,
gui.getSelectedTag, gui.getSelectedTag,
@ -607,15 +617,15 @@ func NewGui(
), ),
Files: controllers.NewFilesController( Files: controllers.NewFilesController(
controllerCommon, controllerCommon,
gui.State.Contexts.Files, func() types.IListContext { return gui.State.Contexts.Files },
gui.git, gui.git,
osCommand, osCommand,
gui.getSelectedFileNode, gui.getSelectedFileNode,
gui.State.Contexts, getContexts,
gui.State.FileTreeViewModel, func() *filetree.FileTreeViewModel { return gui.State.FileTreeViewModel },
gui.enterSubmodule, gui.enterSubmodule,
func() []*models.SubmoduleConfig { return gui.State.Submodules }, func() []*models.SubmoduleConfig { return gui.State.Submodules },
gui.getSetTextareaTextFn(gui.Views.CommitMessage), gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }),
gui.withGpgHandling, gui.withGpgHandling,
func() string { return gui.State.failedCommitMessage }, func() string { return gui.State.failedCommitMessage },
func() []*models.Commit { return gui.State.Commits }, func() []*models.Commit { return gui.State.Commits },
@ -630,7 +640,7 @@ func NewGui(
LocalCommits: controllers.NewLocalCommitsController( LocalCommits: controllers.NewLocalCommitsController(
controllerCommon, controllerCommon,
gui.State.Contexts.BranchCommits, func() types.IListContext { return gui.State.Contexts.BranchCommits },
osCommand, osCommand,
gui.git, gui.git,
refHelper, refHelper,
@ -651,21 +661,21 @@ func NewGui(
Remotes: controllers.NewRemotesController( Remotes: controllers.NewRemotesController(
controllerCommon, controllerCommon,
gui.State.Contexts.Remotes, func() types.IListContext { return gui.State.Contexts.Remotes },
gui.git, gui.git,
gui.State.Contexts, getContexts,
gui.getSelectedRemote, gui.getSelectedRemote,
func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches }, func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches },
gui.Mutexes.FetchMutex, gui.Mutexes.FetchMutex,
), ),
Menu: controllers.NewMenuController( Menu: controllers.NewMenuController(
controllerCommon, controllerCommon,
gui.State.Contexts.Menu, func() types.IListContext { return gui.State.Contexts.Menu },
gui.getSelectedMenuItem, gui.getSelectedMenuItem,
), ),
Bisect: controllers.NewBisectController( Bisect: controllers.NewBisectController(
controllerCommon, controllerCommon,
gui.State.Contexts.BranchCommits, func() types.IListContext { return gui.State.Contexts.BranchCommits },
gui.git, gui.git,
gui.getSelectedLocalCommit, gui.getSelectedLocalCommit,
func() []*models.Commit { return gui.State.Commits }, func() []*models.Commit { return gui.State.Commits },
@ -679,8 +689,6 @@ func NewGui(
), ),
Sync: syncController, Sync: syncController,
} }
return gui, nil
} }
var RuneReplacements = map[rune]string{ var RuneReplacements = map[rune]string{

View File

@ -1400,6 +1400,7 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
gui.Controllers.Bisect, gui.Controllers.Bisect,
gui.Controllers.Undo, gui.Controllers.Undo,
gui.Controllers.Sync, gui.Controllers.Sync,
gui.Controllers.Tags,
} { } {
context := controller.Context() context := controller.Context()
viewName := "" viewName := ""
@ -1422,7 +1423,6 @@ func (gui *Gui) GetInitialKeybindings() []*types.Binding {
for _, listContext := range []types.IListContext{ for _, listContext := range []types.IListContext{
gui.State.Contexts.Branches, gui.State.Contexts.Branches,
gui.State.Contexts.RemoteBranches, gui.State.Contexts.RemoteBranches,
gui.State.Contexts.Tags,
gui.State.Contexts.ReflogCommits, gui.State.Contexts.ReflogCommits,
gui.State.Contexts.SubCommits, gui.State.Contexts.SubCommits,
gui.State.Contexts.Stash, gui.State.Contexts.Stash,

View File

@ -277,6 +277,7 @@ func (self *ListContext) Keybindings(
{ {
Key: getKey(config.Universal.GotoBottom), Key: getKey(config.Universal.GotoBottom),
Description: self.Gui.c.Tr.LcGotoBottom, Description: self.Gui.c.Tr.LcGotoBottom,
Handler: self.HandleGotoBottom,
Tag: "navigation", Tag: "navigation",
}, },
} }

View File

@ -1,10 +1,16 @@
package gui package gui
import "github.com/jesseduffield/lazygit/pkg/commands/models"
// this file is to put things where it's not obvious where they belong while this refactor takes place // this file is to put things where it's not obvious where they belong while this refactor takes place
func (gui *Gui) getSuggestedRemote() string { func (gui *Gui) getSuggestedRemote() string {
remotes := gui.State.Remotes remotes := gui.State.Remotes
return getSuggestedRemote(remotes)
}
func getSuggestedRemote(remotes []*models.Remote) string {
if len(remotes) == 0 { if len(remotes) == 0 {
return "origin" return "origin"
} }

View File

@ -212,6 +212,8 @@ type TestPopupHandler struct {
OnPrompt func(opts PromptOpts) error OnPrompt func(opts PromptOpts) error
} }
var _ IPopupHandler = &TestPopupHandler{}
func (self *TestPopupHandler) Error(err error) error { func (self *TestPopupHandler) Error(err error) error {
return self.ErrorMsg(err.Error()) return self.ErrorMsg(err.Error())
} }
@ -244,6 +246,6 @@ func (self *TestPopupHandler) Toast(message string) {
panic("not yet implemented") panic("not yet implemented")
} }
func (self *TestPopupHandler) CurrentInput() string { func (self *TestPopupHandler) GetPromptInput() string {
panic("not yet implemented") panic("not yet implemented")
} }

View File

@ -16,18 +16,18 @@ type RefHelper struct {
c *controllers.ControllerCommon c *controllers.ControllerCommon
git *commands.GitCommand git *commands.GitCommand
State *GuiRepoState getState func() *GuiRepoState
} }
func NewRefHelper( func NewRefHelper(
c *controllers.ControllerCommon, c *controllers.ControllerCommon,
git *commands.GitCommand, git *commands.GitCommand,
state *GuiRepoState, getState func() *GuiRepoState,
) *RefHelper { ) *RefHelper {
return &RefHelper{ return &RefHelper{
c: c, c: c,
git: git, git: git,
State: state, getState: getState,
} }
} }
@ -42,10 +42,10 @@ func (self *RefHelper) CheckoutRef(ref string, options types.CheckoutRefOptions)
cmdOptions := git_commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars} cmdOptions := git_commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
onSuccess := func() { onSuccess := func() {
self.State.Panels.Branches.SelectedLineIdx = 0 self.getState().Panels.Branches.SelectedLineIdx = 0
self.State.Panels.Commits.SelectedLineIdx = 0 self.getState().Panels.Commits.SelectedLineIdx = 0
// loading a heap of commits is slow so we limit them whenever doing a reset // loading a heap of commits is slow so we limit them whenever doing a reset
self.State.Panels.Commits.LimitCommits = true self.getState().Panels.Commits.LimitCommits = true
} }
return self.c.WithWaitingStatus(waitingStatus, func() error { return self.c.WithWaitingStatus(waitingStatus, func() error {
@ -97,12 +97,12 @@ func (self *RefHelper) ResetToRef(ref string, strength string, envVars []string)
return self.c.Error(err) return self.c.Error(err)
} }
self.State.Panels.Commits.SelectedLineIdx = 0 self.getState().Panels.Commits.SelectedLineIdx = 0
self.State.Panels.ReflogCommits.SelectedLineIdx = 0 self.getState().Panels.ReflogCommits.SelectedLineIdx = 0
// loading a heap of commits is slow so we limit them whenever doing a reset // loading a heap of commits is slow so we limit them whenever doing a reset
self.State.Panels.Commits.LimitCommits = true self.getState().Panels.Commits.LimitCommits = true
if err := self.c.PushContext(self.State.Contexts.BranchCommits); err != nil { if err := self.c.PushContext(self.getState().Contexts.BranchCommits); err != nil {
return err return err
} }

View File

@ -25,7 +25,7 @@ import (
type SuggestionsHelper struct { type SuggestionsHelper struct {
c *controllers.ControllerCommon c *controllers.ControllerCommon
State *GuiRepoState getState func() *GuiRepoState
refreshSuggestionsFn func() refreshSuggestionsFn func()
} }
@ -33,19 +33,19 @@ var _ controllers.ISuggestionsHelper = &SuggestionsHelper{}
func NewSuggestionsHelper( func NewSuggestionsHelper(
c *controllers.ControllerCommon, c *controllers.ControllerCommon,
state *GuiRepoState, getState func() *GuiRepoState,
refreshSuggestionsFn func(), refreshSuggestionsFn func(),
) *SuggestionsHelper { ) *SuggestionsHelper {
return &SuggestionsHelper{ return &SuggestionsHelper{
c: c, c: c,
State: state, getState: getState,
refreshSuggestionsFn: refreshSuggestionsFn, refreshSuggestionsFn: refreshSuggestionsFn,
} }
} }
func (self *SuggestionsHelper) getRemoteNames() []string { func (self *SuggestionsHelper) getRemoteNames() []string {
result := make([]string, len(self.State.Remotes)) result := make([]string, len(self.getState().Remotes))
for i, remote := range self.State.Remotes { for i, remote := range self.getState().Remotes {
result[i] = remote.Name result[i] = remote.Name
} }
return result return result
@ -69,8 +69,8 @@ func (self *SuggestionsHelper) GetRemoteSuggestionsFunc() func(string) []*types.
} }
func (self *SuggestionsHelper) getBranchNames() []string { func (self *SuggestionsHelper) getBranchNames() []string {
result := make([]string, len(self.State.Branches)) result := make([]string, len(self.getState().Branches))
for i, branch := range self.State.Branches { for i, branch := range self.getState().Branches {
result[i] = branch.Name result[i] = branch.Name
} }
return result return result
@ -123,7 +123,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
return nil return nil
}) })
// cache the trie for future use // cache the trie for future use
self.State.FilesTrie = trie self.getState().FilesTrie = trie
self.refreshSuggestionsFn() self.refreshSuggestionsFn()
@ -132,7 +132,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
return func(input string) []*types.Suggestion { return func(input string) []*types.Suggestion {
matchingNames := []string{} matchingNames := []string{}
_ = self.State.FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error { _ = self.getState().FilesTrie.VisitFuzzy(patricia.Prefix(input), true, func(prefix patricia.Prefix, item patricia.Item, skipped int) error {
matchingNames = append(matchingNames, item.(string)) matchingNames = append(matchingNames, item.(string))
return nil return nil
}) })
@ -154,7 +154,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string { func (self *SuggestionsHelper) getRemoteBranchNames(separator string) []string {
result := []string{} result := []string{}
for _, remote := range self.State.Remotes { for _, remote := range self.getState().Remotes {
for _, branch := range remote.Branches { for _, branch := range remote.Branches {
result = append(result, fmt.Sprintf("%s%s%s", remote.Name, separator, branch.Name)) result = append(result, fmt.Sprintf("%s%s%s", remote.Name, separator, branch.Name))
} }
@ -167,8 +167,8 @@ func (self *SuggestionsHelper) GetRemoteBranchesSuggestionsFunc(separator string
} }
func (self *SuggestionsHelper) getTagNames() []string { func (self *SuggestionsHelper) getTagNames() []string {
result := make([]string, len(self.State.Tags)) result := make([]string, len(self.getState().Tags))
for i, tag := range self.State.Tags { for i, tag := range self.getState().Tags {
result[i] = tag.Name result[i] = tag.Name
} }
return result return result

View File

@ -6,17 +6,17 @@ import (
) )
type WorkingTreeHelper struct { type WorkingTreeHelper struct {
fileTreeViewModel *filetree.FileTreeViewModel getFileTreeViewModel func() *filetree.FileTreeViewModel
} }
func NewWorkingTreeHelper(fileTreeViewModel *filetree.FileTreeViewModel) *WorkingTreeHelper { func NewWorkingTreeHelper(getFileTreeViewModel func() *filetree.FileTreeViewModel) *WorkingTreeHelper {
return &WorkingTreeHelper{ return &WorkingTreeHelper{
fileTreeViewModel: fileTreeViewModel, getFileTreeViewModel: getFileTreeViewModel,
} }
} }
func (self *WorkingTreeHelper) AnyStagedFiles() bool { func (self *WorkingTreeHelper) AnyStagedFiles() bool {
files := self.fileTreeViewModel.GetAllFiles() files := self.getFileTreeViewModel().GetAllFiles()
for _, file := range files { for _, file := range files {
if file.HasStagedChanges { if file.HasStagedChanges {
return true return true
@ -26,7 +26,7 @@ func (self *WorkingTreeHelper) AnyStagedFiles() bool {
} }
func (self *WorkingTreeHelper) AnyTrackedFiles() bool { func (self *WorkingTreeHelper) AnyTrackedFiles() bool {
files := self.fileTreeViewModel.GetAllFiles() files := self.getFileTreeViewModel().GetAllFiles()
for _, file := range files { for _, file := range files {
if file.Tracked { if file.Tracked {
return true return true
@ -40,7 +40,7 @@ func (self *WorkingTreeHelper) IsWorkingTreeDirty() bool {
} }
func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File { func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File {
for _, file := range self.fileTreeViewModel.GetAllFiles() { for _, file := range self.getFileTreeViewModel().GetAllFiles() {
if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) { if file.IsSubmodule([]*models.SubmoduleConfig{submodule}) {
return file return file
} }

View File

@ -66,7 +66,6 @@ func chineseTranslationSet() TranslationSet {
LcScroll: "滚动", LcScroll: "滚动",
MergeConflictsTitle: "合并冲突", MergeConflictsTitle: "合并冲突",
LcCheckout: "检出", LcCheckout: "检出",
LcCommitFileFilter: "过滤提交文件",
NoChangedFiles: "没有更改过文件", NoChangedFiles: "没有更改过文件",
NoFilesDisplay: "没有文件可显示", NoFilesDisplay: "没有文件可显示",
NotAFile: "不是文件", NotAFile: "不是文件",

View File

@ -33,7 +33,6 @@ func dutchTranslationSet() TranslationSet {
LcPush: "push", LcPush: "push",
LcPull: "pull", LcPull: "pull",
LcScroll: "scroll", LcScroll: "scroll",
LcCommitFileFilter: "Commit dossiers filteren",
FilterStagedFiles: "Show only staged files", FilterStagedFiles: "Show only staged files",
FilterUnstagedFiles: "Show only unstaged files", FilterUnstagedFiles: "Show only unstaged files",
ResetCommitFilterState: "Reset commit file state filter", ResetCommitFilterState: "Reset commit file state filter",

View File

@ -47,7 +47,6 @@ type TranslationSet struct {
LcPull string LcPull string
LcScroll string LcScroll string
LcFileFilter string LcFileFilter string
LcCommitFileFilter string
FilterStagedFiles string FilterStagedFiles string
FilterUnstagedFiles string FilterUnstagedFiles string
ResetCommitFilterState string ResetCommitFilterState string
@ -622,7 +621,6 @@ func EnglishTranslationSet() TranslationSet {
MergeConflictsTitle: "Merge Conflicts", MergeConflictsTitle: "Merge Conflicts",
LcCheckout: "checkout", LcCheckout: "checkout",
LcFileFilter: "Filter files (staged/unstaged)", LcFileFilter: "Filter files (staged/unstaged)",
LcCommitFileFilter: "Filter commit files",
FilterStagedFiles: "Show only staged files", FilterStagedFiles: "Show only staged files",
FilterUnstagedFiles: "Show only unstaged files", FilterUnstagedFiles: "Show only unstaged files",
ResetCommitFilterState: "Reset filter", ResetCommitFilterState: "Reset filter",

View File

@ -29,7 +29,6 @@ func polishTranslationSet() TranslationSet {
LcToggleStagedAll: "przełącz stan poczekalni wszystkich", LcToggleStagedAll: "przełącz stan poczekalni wszystkich",
LcRefresh: "odśwież", LcRefresh: "odśwież",
LcScroll: "przewiń", LcScroll: "przewiń",
LcCommitFileFilter: "Filtrowanie commitów",
FilterStagedFiles: "Pokaż tylko pliki w poczekalni", FilterStagedFiles: "Pokaż tylko pliki w poczekalni",
FilterUnstagedFiles: "Pokaż tylko pliki poza poczekalnią", FilterUnstagedFiles: "Pokaż tylko pliki poza poczekalnią",
ResetCommitFilterState: "Resetuj filtr commitów", ResetCommitFilterState: "Resetuj filtr commitów",

View File

@ -1,4 +1,4 @@
{ {
"description": "Verify that when we get merge conflicts we filter out any non-conflicted files", "description": "Verify that when we get merge conflicts we filter out any non-conflicted files",
"speed": 20 "speed": 1
} }

3
vendor/modules.txt vendored
View File

@ -100,8 +100,6 @@ github.com/gobwas/glob/syntax/ast
github.com/gobwas/glob/syntax/lexer github.com/gobwas/glob/syntax/lexer
github.com/gobwas/glob/util/runes github.com/gobwas/glob/util/runes
github.com/gobwas/glob/util/strings github.com/gobwas/glob/util/strings
# github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
## explicit
# github.com/golang/protobuf v1.3.2 # github.com/golang/protobuf v1.3.2
## explicit ## explicit
# github.com/google/go-cmp v0.5.6 # github.com/google/go-cmp v0.5.6
@ -268,7 +266,6 @@ golang.org/x/sys/windows
## explicit ## explicit
golang.org/x/term golang.org/x/term
# golang.org/x/text v0.3.7 # golang.org/x/text v0.3.7
## explicit
golang.org/x/text/encoding golang.org/x/text/encoding
golang.org/x/text/encoding/internal/identifier golang.org/x/text/encoding/internal/identifier
golang.org/x/text/transform golang.org/x/text/transform