diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 07:53:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 690c504391e07a0767df8255e288ffe39296af22 (patch) | |
| tree | 162bf46bc8cae3f0cec46b58d3d3cc2ea558a7e3 /src/edit.zig | |
| parent | dee94c740bdaea61ff35b4e0a7f1d2815c9ee441 (diff) | |
| download | pardes-690c504391e07a0767df8255e288ffe39296af22.tar.gz pardes-690c504391e07a0767df8255e288ffe39296af22.zip | |
+39 -6 lib: a new line's indent comes from the parse handed in (docs/next-editor.md): in the library, edit.treeIndent reads normal.nodeTree, the caller's `Syntax`, and its `Language`'s indent query (`indents`, which addLanguage already kept and nothing read), as a file's Enter, `o` and `O` read its own tree; without a query, or without a parse, the plain indent as before (a level more after `(`, `[`, `{` or `)`), which pushed every line of a language whose lines end in a call one level further in (examples/live, the sketch's language); pardes's own panes compile the branch out; test/lib: `f(1)` and Enter with no parse, with a grammar and no indent query (both a level in) and with one (none); hxlib 538 of 658 with 0 mismatches, core-test 811 of 950, shell-test 990 of 993, hxdiff 658 with 0 mismatches, lib-test 11 of 11
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/edit.zig')
| -rw-r--r-- | src/edit.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/edit.zig b/src/edit.zig index 32943c19..fe644541 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -762,8 +762,13 @@ pub fn retireEditText(e: Editor, new: []u8) void { } /// helix's indent for a line opened after byte `at` of `row` (indent.zig), -/// from the file's tree, where its grammar has an indent query. +/// from the file's tree, where its grammar has an indent query; in the +/// library, from the parse handed in (normal.nodeTree), its `Language`'s. fn treeIndent(e: Editor, t: *Text, text: []const u8, row: usize, at: usize) Error!?[]const u8 { + if (comptime Editor.lib) { + const tree = normal.nodeTree(e, t, text) orelse return null; + return indents.forNewline(e.scratch, indents.lang(tree.path) orelse return null, tree.root, text, row, at); + } const f = bodyFile(t) orelse return null; const l = indents.lang(f.path) orelse return null; const tree = normal.fileTree(e.p, f) orelse return null; |
