Commit 38ebdc8
committed
Bugfix: cursor lands on new folder, not the row below
- After F7/Shift+F4, `create_directory`/`create_file` queue a synthetic `directory-diff` with 50 ms trailing-window coalesce (diff_emitter). The optimistic `setCursorIndex` in `moveCursorToNewFolder` landed correctly, but when the deferred diff fired, `FilePane`'s diff handler ran the new entry's index through `adjustSelectionIndices` and shifted the cursor +1 (an `add` at the cursor's index pushes the cursor down).
- Fix: `moveCursorToNewFolder` now also calls `paneRef.setPendingCursorName(name)`. The diff handler already reads `pendingCursorName` for the rename flow — when the diff lands, it re-pins the cursor by name and `return`s before the structural shift runs. Reuses the existing channel rather than adding a parallel one.
- New `FilePaneAPI.setPendingCursorName(name)` exposes the field; current call site is `moveCursorToNewFolder`, also used by mkfile via the shared helper.
- E2E regression guard: `file-operations.spec.ts › Create folder round-trip › cursor lands on the newly created folder` — picks a name that sorts between two existing dirs (`bulk` < `mid-cursor-…` < `sub-dir`) so an off-by-one shift surfaces as a different filename. Asserts cursor name 5× at 80 ms intervals.
- `CLAUDE.md` gotcha added so the next agent doesn't re-introduce the race.1 parent 91962d2 commit 38ebdc8
5 files changed
Lines changed: 71 additions & 0 deletions
File tree
- apps/desktop
- src/lib
- file-explorer/pane
- file-operations
- mkdir
- test/e2e-playwright
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
556 | 567 | | |
557 | 568 | | |
558 | 569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
214 | 251 | | |
215 | 252 | | |
216 | 253 | | |
| |||
0 commit comments