summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-08 10:44:56 -0300
committerGabriel Schneider <[email protected]>2026-08-10 09:17:07 -0300
commit198889ab8f78b12c9881a20309a792e419ba1386 (patch)
tree264bb756389f4c4cbaf68a6a2aabf3d602450a36 /src/builtins.zig
parentc3c8bbd8d8add99088c774c54bc1acf1e39ec895 (diff)
downloadpardes-198889ab8f78b12c9881a20309a792e419ba1386.tar.gz
pardes-198889ab8f78b12c9881a20309a792e419ba1386.zip
Esc alternates between the last two panes; Toggleterm is gone
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.
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 9fa459f2..b1380203 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -526,40 +526,6 @@ pub const Right = struct {
}
};
-/// The file<->terminal hop. "Latest" is already recorded: the jump stack runs
-/// oldest-first and a closing pane hands focus back through the same list — so
-/// this walks it instead of keeping a second one. Which side is which: only a
-/// shell is a terminal; a file, an image and an output buffer (+Search/+Help)
-/// are all DOCS you read, so isTerminal is the whole test. Landing pushes this
-/// pane onto that same history, which is why the hop back is the same key.
-pub const Toggleterm = struct {
- pub fn run(c: Ctx) void {
- const want_term = !c.pane.isTerminal();
- var t: ?usize = null;
- // any live pane of the other kind: a pane you have never focused (the
- // file you started with) is in no history at all
- for (c.p.panes, 0..) |slot, k| {
- const op = slot orelse continue;
- if (k != c.id and op.isTerminal() == want_term) t = k;
- }
- // ...but the most recently focused one wins
- var i = c.p.njumps;
- while (i > 0) {
- i -= 1;
- const hid = c.p.jumps[i].pane;
- const hp = c.p.panes[hid] orelse continue;
- if (hid != c.id and hp.isTerminal() == want_term) {
- t = hid;
- break;
- }
- }
- if (t) |target| {
- c.p.active = target;
- c.p.panes[target].?.pending = 0;
- }
- }
-};
-
// ---- the jump group ----
// Where focus HAS BEEN, as three verbs and a list over the one stack pardes
@@ -583,12 +549,20 @@ pub const Forward = struct {
};
/// vim's Ctrl-^: the pane you were in before this one, whichever it was — the
-/// hop you press twice a minute and never want to count steps for.
+/// hop you press twice a minute and never want to count steps for. Body-normal
+/// Esc is this, which is what makes alternating between two panes one key you
+/// hold down: two files, or a file and its shell, or a file and a +Search.
///
/// It does NOT move the stack cursor: it goes somewhere, so trackJump records
/// it like any other move, and that is exactly what makes it an involution —
/// after the hop, the pane you came from is the newest OTHER pane, so pressing
/// it again comes straight back. Back/Forward walk history; this one makes it.
+///
+/// It replaced a `Toggleterm` that hopped specifically 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),
+/// and it could not alternate between two files at all — the case you hit most.
+/// "The pane before this one" needs no kinds and is the same key twice.
pub const Last = struct {
pub fn run(c: Ctx) void {
var i = c.p.njumps;