Commit 9f23b89
authored
Improve hunk selection mode in staging view (#4684)
- **PR Description** Hunk selection mode is one of the features that many people don't know about, because it is not very discoverable. You can switch to it from line selection mode by pressing `a` in the staging view. The problem with this mode is that it selects entire hunks, where hunks are defined to be sections of the diff starting with `@@`. Very often, hunks consist of multiple distinct blocks of changes, separated by context lines. For example, with the default diff context size of 3 it takes at least 6 unchanged lines between blocks of changes for them to be separated into distinct hunks; if there are 5 or less unchanged lines between them, they are grouped into one hunk. And of course, if you increase the diff context size by pressing `}`, you will get even fewer hunks. Now, most of the time I want to navigate between the individual blocks of changes in a diff, regardless of how git groups them into hunks. That's what this PR does: when pressing `a`, the selection is extended to just the current group of changes, separated by context lines; you can easily stage it by pressing space, and the selection will move on to the next block of changes. Actual hunks no longer play a role here. Also, in line selection mode the right/left arrow keys now move between blocks of changes rather than actual hunks. I find this new behavior so useful that I almost always switch to hunk mode right away after entering the staging view. It saves a lot of keystrokes, since it is very rare that I want to select only some lines of a block of adjacent changes. This makes me wonder whether we should enable hunk mode by default when entering staging, but that's going to be another PR.File tree
6 files changed
+94
-136
lines changed- .vscode
- pkg
- gui
- controllers
- patch_exploring
- integration/tests
- patch_building
- staging
6 files changed
+94
-136
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
| |||
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
206 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
216 | 227 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
224 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
225 | 254 | | |
226 | 255 | | |
227 | 256 | | |
| |||
259 | 288 | | |
260 | 289 | | |
261 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
262 | 315 | | |
263 | 316 | | |
264 | 317 | | |
265 | | - | |
266 | | - | |
| 318 | + | |
267 | 319 | | |
268 | 320 | | |
269 | 321 | | |
| |||
Lines changed: 3 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 60 | | |
68 | 61 | | |
69 | 62 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 63 | + | |
| 64 | + | |
83 | 65 | | |
84 | 66 | | |
85 | 67 | | |
| |||
154 | 136 | | |
155 | 137 | | |
156 | 138 | | |
157 | | - | |
158 | | - | |
| 139 | + | |
159 | 140 | | |
160 | 141 | | |
161 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 55 | | |
59 | 56 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 57 | | |
64 | 58 | | |
65 | 59 | | |
66 | 60 | | |
67 | 61 | | |
68 | 62 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 63 | | |
73 | 64 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | 65 | | |
79 | 66 | | |
80 | 67 | | |
81 | 68 | | |
82 | 69 | | |
83 | 70 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 71 | | |
88 | 72 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 73 | | |
93 | 74 | | |
94 | 75 | | |
95 | 76 | | |
96 | 77 | | |
97 | 78 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 79 | | |
102 | 80 | | |
103 | | - | |
104 | | - | |
105 | 81 | | |
106 | 82 | | |
107 | 83 | | |
108 | 84 | | |
109 | 85 | | |
110 | 86 | | |
111 | | - | |
112 | | - | |
113 | 87 | | |
114 | 88 | | |
115 | | - | |
116 | 89 | | |
117 | 90 | | |
118 | 91 | | |
| |||
121 | 94 | | |
122 | 95 | | |
123 | 96 | | |
124 | | - | |
125 | | - | |
126 | 97 | | |
127 | 98 | | |
128 | | - | |
129 | 99 | | |
130 | 100 | | |
131 | 101 | | |
132 | 102 | | |
133 | 103 | | |
134 | 104 | | |
135 | | - | |
136 | 105 | | |
137 | 106 | | |
138 | 107 | | |
| |||
141 | 110 | | |
142 | 111 | | |
143 | 112 | | |
144 | | - | |
145 | | - | |
146 | 113 | | |
147 | 114 | | |
148 | | - | |
149 | 115 | | |
150 | 116 | | |
151 | 117 | | |
152 | 118 | | |
153 | 119 | | |
154 | 120 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 121 | | |
159 | 122 | | |
160 | | - | |
161 | | - | |
162 | 123 | | |
163 | 124 | | |
164 | 125 | | |
0 commit comments