diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 03:35:02 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 04:08:16 -0300 |
| commit | c0ed5f823a37fb1b9b2300f53b23263bfc97a108 (patch) | |
| tree | c99677eaad7f76b515827ac5c562434902033a92 /test/behaviour | |
| parent | e398c24ba19948727affdc6a29254ac69a6b7699 (diff) | |
| download | pardes-c0ed5f823a37fb1b9b2300f53b23263bfc97a108.tar.gz pardes-c0ed5f823a37fb1b9b2300f53b23263bfc97a108.zip | |
edit: Enter, o and O give the new line helix's indent where the file's grammar has an indent query, its indent_for_newline over the file's tree (indent.zig: the reference's containment engine, every capture and predicate the vendored queries use, the hybrid heuristic), else acme's copy as before; and Enter between a pair puts the closer on a line of its own at that indent and the cursor on one a level in, as helix's insert_newline does, in plain text too
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/from_acme.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/behaviour/from_acme.zig b/test/behaviour/from_acme.zig index 62d4fc55..26f8a820 100644 --- a/test/behaviour/from_acme.zig +++ b/test/behaviour/from_acme.zig @@ -26,3 +26,33 @@ test "from-acme: acme's words run as pardes's (Put is Save, Delete a Del that do try s.write(s.at("/pane/{d}/ctl", .{made}), "Delete\n"); try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "/tmp/pardes-delete.txt") == null); } + +/// A file pane named `name` (its extension picks its grammar) holding +/// `text`, after `keys` and a `|` typed where they left the cursor. +fn expectTyped(name: []const u8, text: []const u8, keys: []const u8, want: []const u8) !void { + var s = try Session.initFile(std.testing.allocator, text); + defer s.deinit(); + const n = try s.focused(); + try s.write(s.at("/pane/{d}/name", .{n}), name); + try s.keys(keys); + try s.keys("|"); + try s.expect(s.at("/pane/{d}/body", .{n}), want); +} + +test "from-acme: Indent: Enter, o and O in a file whose grammar has an indent query take helix's indent from its tree, a typed closer left where it is" { + try expectTyped("/x.zig", "fn f() void {\n}\n", "A\n", "fn f() void {\n |\n}\n"); + try expectTyped("/x.zig", "fn f() void {\n a();}\n", "jgli\n", "fn f() void {\n a();\n|}\n"); + try expectTyped("/x.zig", "fn f() void {\n a();\n}\n", "jo}", "fn f() void {\n a();\n }|\n}\n"); + try expectTyped("/x.py", "def f():\n pass\n", "A\n", "def f():\n |\n pass\n"); + try expectTyped("/x.py", "def f():\n return 1\n", "jA\n", "def f():\n return 1\n|\n"); + try expectTyped("/x.rs", "fn f() {\n a();\n}\n", "jo", "fn f() {\n a();\n |\n}\n"); + try expectTyped("/x.rs", "fn f() {\n a();\n}\n", "jjO", "fn f() {\n a();\n |\n}\n"); + // no grammar: the line's own indent, as it is + try expectTyped("/x.txt", "a\n b\n", "jA\n", "a\n b\n |\n"); +} + +test "from-acme: Indent: Enter between a pair puts the closer on a line of its own at the new line's indent and the cursor a level in, in plain text too" { + try expectTyped("/x.zig", "fn f() void {}\n", "gli\n", "fn f() void {\n |\n}\n"); + try expectTyped("/x.py", "x = []\n", "gli\n", "x = [\n |\n]\n"); + try expectTyped("/x.txt", "a\n x {}\n", "jgli\n", "a\n x {\n |\n }\n"); +} |
