summaryrefslogtreecommitdiff
path: root/src/normal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/normal.zig')
-rw-r--r--src/normal.zig23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/normal.zig b/src/normal.zig
index e4fa075d..630f7689 100644
--- a/src/normal.zig
+++ b/src/normal.zig
@@ -173,7 +173,9 @@ const Replay = union(enum) {
pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void {
const id = p.active;
- const serial = t.pane().serial;
+ // a header belongs to no pane and cannot go away under the replay
+ const owner: ?*Pane = if (t.what == .column or t.what == .workspace) null else t.pane();
+ const serial = if (owner) |pane| pane.serial else 0;
// the whole selection in text coordinates, document order. t.sels
// is already ordered, so this only slots the primary into place.
var list: [Text.max_selections]Text.SelRange = undefined;
@@ -256,8 +258,11 @@ pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void {
p.multi_first = false;
if (p.multi_stop) {
p.multi_stop = false;
- const pn = p.panes[id] orelse return;
- if (pn.serial == serial) t.nsel = 0;
+ if (owner != null) {
+ const pn = p.panes[id] orelse return;
+ if (pn.serial != serial) return;
+ }
+ t.nsel = 0;
return;
}
const text = edit.flatSurface(p, t) catch return;
@@ -284,7 +289,9 @@ pub fn handleNormal(p: *Pardes, t: *Text, key: Key) void {
}
fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void {
- const pane = t.pane();
+ // What reaches past the text -- a builtin, a search, a language query --
+ // acts for the pane the text belongs to; a header's is the active one.
+ const pane = if (t.what == .column or t.what == .workspace) p.panes[p.active] orelse return else t.pane();
const raw_selection = t.what == .body and pane.rawPointerText(pane.sel[sel_slot]) != null;
const before = .{ t.cur_row, t.cur_col, t.vsel, t.msel, t.select, t.nsel, t.mode };
defer if (raw_selection and !std.meta.eql(before, .{ t.cur_row, t.cur_col, t.vsel, t.msel, t.select, t.nsel, t.mode })) {
@@ -547,9 +554,11 @@ fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void
},
// `:` is the one key a tag and a body do not share: it moves the
// keyboard between them.
- .command_line => if (t.what == .tag) {
- pane.focus = .body;
- } else p.enterTag(pane),
+ .command_line => switch (t.what) {
+ .tag => pane.focus = .body,
+ .column, .workspace => p.exitHeader(),
+ .body, .input => p.enterTag(pane),
+ },
.pipe_selection => |how| return p.startPrompt(pane, .{ .pipe = how }),
.search => return p.startPrompt(pane, .{ .search = config.search_marker }),
.search_step => |direction| return look.lookWalk(