summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 08:58:46 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit66c0106691e4de925011f314200e85ee265b7861 (patch)
tree8c9172bd1c51de1abea67d0f75c598d32a9ae53f /src
parent590e98bc3a198b86aaeca2168c4ac65d5cd777d0 (diff)
downloadpardes-66c0106691e4de925011f314200e85ee265b7861.tar.gz
pardes-66c0106691e4de925011f314200e85ee265b7861.zip
Run the word under the cursor when Enter is pressed in a header
The workspace and column tags hold nothing but commands, and before they became texts Enter on one of them ran it: Enter on Newcol made a column. Since then Enter looked the word up, as it does in a pane's tag, which only searched for it. It runs it again, and the header lets go of the keyboard first as a pane tag does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/pardes.zig18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index b7cf5574..3194b059 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2911,6 +2911,19 @@ test "a header's execute key runs the word under its cursor and lets go of the k
try std.testing.expectEqual(@as(usize, 1), p.col_n[0]);
}
+test "Enter in a header runs the word under its cursor, as the execute key does" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 12, .tty_only = true });
+ defer p.deinit();
+ _ = try p.setTestFile("body\n");
+ try std.testing.expectEqual(@as(usize, 1), p.ncol);
+ tagline.enterHeader(p, null);
+ p.global_tag.cur_col = @intCast(std.mem.indexOf(u8, config.topbar_str, "Newcol").?);
+ p.update(.{ .key = .{ .cp = Key.enter } });
+ try std.testing.expectEqual(@as(usize, 2), p.ncol);
+ // and the header lets go of the keyboard, as a pane tag does
+ try std.testing.expect(!p.header_focus);
+}
+
test "window keys walk from a pane up through the column and workspace tags and back" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 20, .tty_only = true });
defer p.deinit();
@@ -4933,7 +4946,10 @@ pub const Pardes = struct {
return;
}
if (t.mode == .normal and (hit(key, config.look_key) or hit(key, config.exec_key))) {
- const cmd = if (hit(key, config.look_key)) config.look_cmd else config.exec_cmd;
+ // A header's words are the workspace's and column's commands, so
+ // Enter runs them there, as the execute key does.
+ const header_word = t.what == .column or t.what == .workspace;
+ const cmd = if (hit(key, config.look_key) and !header_word) config.look_cmd else config.exec_cmd;
if (t.what != .body) {
// An explicit selection, else the word under the cursor in the
// text as it is shown: a tag's prefix is part of what a word is.