Skip to content

Commit 3541b09

Browse files
authored
Enable hunk staging mode by default (#4780)
- **PR Description** In #4684 we improved the hunk selection behavior to work on blocks of changes instead of actual hunks, and I find this so useful that I wanted to use it by default. In #4685 I added a user config to make hunk selection the default, but I made it an opt-in config because I was worried that users might not find out how to switch back to line selection if needed. To address this concern, in this PR I add a popup that explains this the first time the user enters staging; there is also a breaking changes notice at startup, and we improve the options display at the bottom of the screen to be clearer about this. Hopefully these measures are enough to not confuse people. Closes #4759.
2 parents 98801da + c216388 commit 3541b09

29 files changed

+129
-54
lines changed

docs/Config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ gui:
117117
wrapLinesInStagingView: true
118118

119119
# If true, hunk selection mode will be enabled by default when entering the staging view.
120-
useHunkModeInStagingView: false
120+
useHunkModeInStagingView: true
121121

122122
# One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru'
123123
language: auto

docs/keybindings/Keybindings_en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
221221
| `` <left> `` | Go to previous hunk | |
222222
| `` <right> `` | Go to next hunk | |
223223
| `` v `` | Toggle range select | |
224-
| `` a `` | Select hunk | Toggle hunk selection mode. |
224+
| `` a `` | Toggle hunk selection | Toggle line-by-line vs. hunk selection mode. |
225225
| `` <c-o> `` | Copy selected text to clipboard | |
226226
| `` o `` | Open file | Open file in default application. |
227227
| `` e `` | Edit file | Open file in external editor. |
@@ -236,7 +236,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
236236
| `` <left> `` | Go to previous hunk | |
237237
| `` <right> `` | Go to next hunk | |
238238
| `` v `` | Toggle range select | |
239-
| `` a `` | Select hunk | Toggle hunk selection mode. |
239+
| `` a `` | Toggle hunk selection | Toggle line-by-line vs. hunk selection mode. |
240240
| `` <c-o> `` | Copy selected text to clipboard | |
241241
| `` <space> `` | Stage | Toggle selection staged / unstaged. |
242242
| `` d `` | Discard | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |

docs/keybindings/Keybindings_ko.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
164164
| `` <left> `` | 이전 hunk를 선택 | |
165165
| `` <right> `` | 다음 hunk를 선택 | |
166166
| `` v `` | 드래그 선택 전환 | |
167-
| `` a `` | Toggle select hunk | Toggle hunk selection mode. |
167+
| `` a `` | Toggle select hunk | Toggle line-by-line vs. hunk selection mode. |
168168
| `` <c-o> `` | 선택한 텍스트를 클립보드에 복사 | |
169169
| `` o `` | 파일 닫기 | Open file in default application. |
170170
| `` e `` | 파일 편집 | Open file in external editor. |
@@ -179,7 +179,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
179179
| `` <left> `` | 이전 hunk를 선택 | |
180180
| `` <right> `` | 다음 hunk를 선택 | |
181181
| `` v `` | 드래그 선택 전환 | |
182-
| `` a `` | Toggle select hunk | Toggle hunk selection mode. |
182+
| `` a `` | Toggle select hunk | Toggle line-by-line vs. hunk selection mode. |
183183
| `` <c-o> `` | 선택한 텍스트를 클립보드에 복사 | |
184184
| `` <space> `` | Staged 전환 | 선택한 행을 staged / unstaged |
185185
| `` d `` | 변경을 삭제 (git reset) | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |

docs/keybindings/Keybindings_nl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
229229
| `` <left> `` | Selecteer de vorige hunk | |
230230
| `` <right> `` | Selecteer de volgende hunk | |
231231
| `` v `` | Toggle drag selecteer | |
232-
| `` a `` | Toggle selecteer hunk | Toggle hunk selection mode. |
232+
| `` a `` | Toggle selecteer hunk | Toggle line-by-line vs. hunk selection mode. |
233233
| `` <c-o> `` | Copy selected text to clipboard | |
234234
| `` o `` | Open bestand | Open file in default application. |
235235
| `` e `` | Verander bestand | Open file in external editor. |
@@ -302,7 +302,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
302302
| `` <left> `` | Selecteer de vorige hunk | |
303303
| `` <right> `` | Selecteer de volgende hunk | |
304304
| `` v `` | Toggle drag selecteer | |
305-
| `` a `` | Toggle selecteer hunk | Toggle hunk selection mode. |
305+
| `` a `` | Toggle selecteer hunk | Toggle line-by-line vs. hunk selection mode. |
306306
| `` <c-o> `` | Copy selected text to clipboard | |
307307
| `` <space> `` | Toggle staged | Toggle lijnen staged / unstaged |
308308
| `` d `` | Verwijdert change (git reset) | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |

docs/keybindings/Keybindings_ru.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ _Связки клавиш_
7676
| `` <left> `` | Выбрать предыдущую часть | |
7777
| `` <right> `` | Выбрать следующую часть | |
7878
| `` v `` | Переключить выборку перетаскивания | |
79-
| `` a `` | Переключить выборку частей | Toggle hunk selection mode. |
79+
| `` a `` | Переключить выборку частей | Toggle line-by-line vs. hunk selection mode. |
8080
| `` <c-o> `` | Скопировать выделенный текст в буфер обмена | |
8181
| `` <space> `` | Переключить индекс | Переключить строку в проиндексированные / непроиндексированные |
8282
| `` d `` | Отменить изменение (git reset) | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |
@@ -124,7 +124,7 @@ _Связки клавиш_
124124
| `` <left> `` | Выбрать предыдущую часть | |
125125
| `` <right> `` | Выбрать следующую часть | |
126126
| `` v `` | Переключить выборку перетаскивания | |
127-
| `` a `` | Переключить выборку частей | Toggle hunk selection mode. |
127+
| `` a `` | Переключить выборку частей | Toggle line-by-line vs. hunk selection mode. |
128128
| `` <c-o> `` | Скопировать выделенный текст в буфер обмена | |
129129
| `` o `` | Открыть файл | Open file in default application. |
130130
| `` e `` | Редактировать файл | Open file in external editor. |

docs/keybindings/Keybindings_zh-TW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
5858
| `` <left> `` | 選擇上一段 | |
5959
| `` <right> `` | 選擇下一段 | |
6060
| `` v `` | 切換拖曳選擇 | |
61-
| `` a `` | 切換選擇程式碼塊 | Toggle hunk selection mode. |
61+
| `` a `` | 切換選擇程式碼塊 | Toggle line-by-line vs. hunk selection mode. |
6262
| `` <c-o> `` | 複製所選文本至剪貼簿 | |
6363
| `` o `` | 開啟檔案 | 使用預設軟體開啟 |
6464
| `` e `` | 編輯檔案 | 使用外部編輯器開啟 |
@@ -99,7 +99,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
9999
| `` <left> `` | 選擇上一段 | |
100100
| `` <right> `` | 選擇下一段 | |
101101
| `` v `` | 切換拖曳選擇 | |
102-
| `` a `` | 切換選擇程式碼塊 | Toggle hunk selection mode. |
102+
| `` a `` | 切換選擇程式碼塊 | Toggle line-by-line vs. hunk selection mode. |
103103
| `` <c-o> `` | 複製所選文本至剪貼簿 | |
104104
| `` <space> `` | 切換預存 | 切換現有行的狀態 (已預存/未預存) |
105105
| `` d `` | 刪除變更 (git reset) | When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change. |

pkg/app/entry_point.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes
141141

142142
if integrationTest != nil {
143143
integrationTest.SetupConfig(appConfig)
144+
// Set this to true so that integration tests don't have to explicitly deal with the hunk
145+
// staging hint:
146+
appConfig.GetAppState().DidShowHunkStagingHint = true
144147

145148
// Preserve the changes that the test setup just made to the config, so
146149
// they don't get lost when we reload the config while running the test

pkg/config/app_config.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -656,10 +656,11 @@ func (c *AppConfig) SaveGlobalUserConfig() {
656656
// AppState stores data between runs of the app like when the last update check
657657
// was performed and which other repos have been checked out
658658
type AppState struct {
659-
LastUpdateCheck int64
660-
RecentRepos []string
661-
StartupPopupVersion int
662-
LastVersion string // this is the last version the user was using, for the purpose of showing release notes
659+
LastUpdateCheck int64
660+
RecentRepos []string
661+
StartupPopupVersion int
662+
DidShowHunkStagingHint bool
663+
LastVersion string // this is the last version the user was using, for the purpose of showing release notes
663664

664665
// these are for shell commands typed in directly, not for custom commands in the lazygit config.
665666
// For backwards compatibility we keep the old name in yaml files.
@@ -669,12 +670,7 @@ type AppState struct {
669670
}
670671

671672
func getDefaultAppState() *AppState {
672-
return &AppState{
673-
LastUpdateCheck: 0,
674-
RecentRepos: []string{},
675-
StartupPopupVersion: 0,
676-
LastVersion: "",
677-
}
673+
return &AppState{}
678674
}
679675

680676
func LogPath() (string, error) {

pkg/config/user_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ func GetDefaultConfig() *UserConfig {
739739
MainPanelSplitMode: "flexible",
740740
EnlargedSideViewLocation: "left",
741741
WrapLinesInStagingView: true,
742-
UseHunkModeInStagingView: false,
742+
UseHunkModeInStagingView: true,
743743
Language: "auto",
744744
TimeFormat: "02 Jan 06",
745745
ShortTimeFormat: time.Kitchen,

pkg/gui/controllers/commits_files_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode
494494
}
495495

496496
self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts)
497+
self.c.Helpers().PatchBuilding.ShowHunkStagingHint()
498+
497499
return nil
498500
},
499501
})

0 commit comments

Comments
 (0)