From 198889ab8f78b12c9881a20309a792e419ba1386 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 8 Aug 2026 10:44:56 -0300 Subject: Esc alternates between the last two panes; Toggleterm is gone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Esc ran Toggleterm, which hopped between the newest DOC and the newest TERMINAL. That distinction never earned its keep. It made Esc unpredictable — which of three panes you landed on depended on their kinds, not on where you had been — and it could not alternate between two files at all, which is the case you hit most. Editing two files, Esc did nothing. The replacement already existed. Last (SPC j j) is "the pane you were in before this one, whichever it was": it walks the jump stack for the newest entry naming a different pane and restores its line and column. So Esc, and Shift-Esc in tty, now run Last, and Toggleterm is deleted rather than renamed — a third implementation of "go to the other pane" was the thing to avoid. SPC w t goes with it; the w group is the four directional moves, and the jump group already had SPC j j. Held down, Esc alternates. Two files, a file and its shell, a file and a +Search — all the same, because Last has no notion of kind to get wrong. This depends on the swap in the same series: Last reads the stack backwards, and until hopping stopped appending, the pane you came from could fall off it. windownav.snap needed only its keys and prose changed — its golden did not move at all, which is the useful evidence here: for the one scenario the old builtin handled well, Last produces an identical focus sequence. Coverage for what it did not handle is new: a unit test opens a second FILE by looking its name and asserts Esc alternates between two panes of the SAME kind, which is the case that used to be a no-op. Docs follow: tutor.txt, docs/helix-keys.md, docs/design.typ, and the builtin index goldens, which are now one row shorter. 75/75 snapshots, both unit suites, and the macOS ABI build all pass. --- test/snapshots/windownav.snap | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'test/snapshots/windownav.snap') diff --git a/test/snapshots/windownav.snap b/test/snapshots/windownav.snap index 5652116b..c9de55ac 100644 --- a/test/snapshots/windownav.snap +++ b/test/snapshots/windownav.snap @@ -1,12 +1,11 @@ # RULE: moving focus is a BUILTIN like any other, so there is ONE # implementation and every route reaches it. SPC w h/j/k/l run Left/Down/Up/ -# Right — the geometric focusDir the Ctrl-w prefix also runs — and SPC w t -# plus body-normal Esc run Toggleterm, the hop between the most recently -# focused DOCUMENT (a file, an image, a +Search/+Help output buffer: things -# you READ) and the most -# recently focused TERMINAL. "Most recent" is the focus history the core -# already keeps to hand focus back when a pane closes, so the hop back is the -# same key. Focus shows up in the golden's `cursor=` header: that is the +# Right — the geometric focusDir the Ctrl-w prefix also runs — and SPC j j +# plus body-normal Esc run Last, the hop to the pane you were in BEFORE this +# one, whichever kind it was. It reads the focus history the core already keeps +# to hand focus back when a pane closes, and going somewhere is itself recorded, +# which is what makes the hop back the same key. Focus shows up in the golden's +# `cursor=` header: that is the # ACTIVE pane's cursor, so each snap is named by the pane it should land in. file w.txt alpha\nbeta\ngamma start 30 100 w.txt @@ -15,22 +14,20 @@ wait 8000 w.txt stable 700 20000 # A FILE boots alone now, so the terminal every hop below needs is opened here: # SPC c n (Newcol) puts it in a column of its own on the right and focuses it, -# SPC w h comes straight back. WHAT THIS COST: the first SPC w t used to run -# against a shell that had never been focused, which is Toggleterm's fallback -# scan; nothing reaches that branch any more, because every way a script has of -# making a terminal also focuses it. +# SPC w h comes straight back — which also puts the shell on the stack, and Last +# only ever names a pane that is on it. key space c n stable 700 15000 key space w h stable 400 5000 # left column = the file, right column = that shell; the file has focus snap start -# SPC w t: the hop to the most recently focused TERMINAL, the one just opened -key space w t +# SPC j j: the pane before this one, which is the shell just opened +key space j j stable 400 5000 snap to-term -# ...and back, because the file is now the latest document -key space w t +# ...and back, because going there made the file the pane before THAT +key space j j stable 400 5000 snap back-to-file # A bare Esc from a body in normal mode dispatches that SAME builtin: file to @@ -63,12 +60,12 @@ snap left key space w j stable 400 5000 snap down -# SPC w t from a terminal: the file, which is the only document here -key space w t +# SPC j j from a terminal: the file, which is where SPC w h left off +key space j j stable 400 5000 snap toggle-doc -# ...and back to the LATEST terminal — the one just left, not the launch shell -# in the right column, which was focused earlier -key space w t +# ...and back to the shell just left, not the launch shell in the right column, +# which was focused earlier +key space j j stable 400 5000 snap toggle-back -- cgit v1.3