diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 08:12:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 6535f3a59bb2454a0e945d840c083b2423a80b44 (patch) | |
| tree | dbf7e91609275efadc4c9bac7ac9e8e9056d7312 /test/lib | |
| parent | 0db7861d9da09e059fa1b9e40fff5cd52add27f2 (diff) | |
| parent | 690c504391e07a0767df8255e288ffe39296af22 (diff) | |
| download | pardes-6535f3a59bb2454a0e945d840c083b2423a80b44.tar.gz pardes-6535f3a59bb2454a0e945d840c083b2423a80b44.zip | |
integration: the editor library's indent from the handed-in parse, with the rest
A merge of pardes-next (pumzrknp) and editor-lib (uuuzkvmv), no conflicts; the one change it brings is compiled out of pardes's own panes. On tui core-test 811/950 (139 skipped), shell-test 990/993, lib-test, hxdiff 658 and hxlib 538 with 0 mismatches; on gui core-test 811/950.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/lib')
| -rw-r--r-- | test/lib/editor.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lib/editor.zig b/test/lib/editor.zig index 2784b176..22690915 100644 --- a/test/lib/editor.zig +++ b/test/lib/editor.zig @@ -214,3 +214,28 @@ test "a byte range replaced is one step to undo, the ranges following it; a drag try std.testing.expectEqual(pe.Outcome{ .refused = .text_full }, ed.replace(a, 0, 1, &ys, false)); try std.testing.expectEqualSlices(u8, std.mem.asBytes(kept), std.mem.asBytes(ed)); } + +test "a new line's indent comes from the parse handed in, where its language has an indent query; else the plain one" { + const gpa = std.testing.allocator; + pe.syntax.start(gpa); + defer pe.syntax.stop(); + var buf: [4096]u8 = undefined; + // the plain indent is a level more after `)`: what a language whose + // lines are calls does not want, and says by an indent query + for ([_]struct { ?pe.Language, []const u8 }{ + .{ null, "f(1)\n y" }, + .{ .{ .name = "mine", .ext = ".mine", .ts = tree_sitter_c() }, "f(1)\n y" }, + .{ .{ .name = "mine", .ext = ".mine", .ts = tree_sitter_c(), .indents = "(compound_statement) @indent \"}\" @outdent" }, "f(1)\ny" }, + }) |case| { + const ed = try gpa.create(Ed); + defer gpa.destroy(ed); + ed.* = .{}; + var syn: pe.Syntax = .{ .lang = case[0] }; + defer syn.forget(); + try ed.load("f(1)"); + var arena = std.heap.ArenaAllocator.init(gpa); + defer arena.deinit(); + for ([_]pe.Key{ .{ .cp = 'A', .text = "A" }, .{ .cp = pe.Key.enter }, .{ .cp = 'y', .text = "y" }, .{ .cp = pe.Key.escape } }) |k| _ = ed.key(arena.allocator(), &syn, k); + try std.testing.expectEqualStrings(case[1], text(ed, &buf)); + } +} |
