diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 15:38:37 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 15:40:56 -0300 |
| commit | 68b696ead861bb416c339f624bea82ed478bb2dd (patch) | |
| tree | 95605dee66b8f3419bf0a4715d17b3493de1492c /core/edit.zig | |
| parent | 3e60c54651f10fe9233a40bc1f1fdaed141d2116 (diff) | |
| download | pardes-68b696ead861bb416c339f624bea82ed478bb2dd.tar.gz pardes-68b696ead861bb416c339f624bea82ed478bb2dd.zip | |
changes layer: the node keys and the indent parse the FILE's text, as every other parse does (round 8 left them parsing the buffer with the layer's lines in it): `normal.fileTree` parses `File.fileText` (the buffer itself with no layer: a length test), and `Editor.Tree` carries the text it parsed and the file whose buffer the keys' places are of, `in` (a buffer place as the tree's: `File.fileOffset`) and `out` (back: `File.bufferOffset`, a range's end before the layer's lines standing there; the library's text is its own: both the identity at comptime): Alt-o and kin (`nodeSelect`: the walk asked in the file's places, its spans mapped back), `]f` and kin (`objectJump`), a tree-sitter text object (`maf` and kin, edit.zig), and `o`'s indent (`treeIndent`: the file's text, row and offset with the layer shown; unchanged with none); `File.edit` tells the kept tree of no edit with the layer's lines in the buffer or going in or out (`told`, `read_only`): it is the file's text's, parsed anew at the next key; THE FAILING TEST FIRST (core/jj.zig "the node keys and the indent read the file's text ..."): with the layer shown and hidden, the cursor on `c2();`, Alt-o once, twice and three times and `maf` give the same range of the file's text (9P's `dot`), and `o` the same new line: on the round's base the function's text object selected nothing beside the layer's lines (27..27 where hidden 0..34: the description line in the buffer broke the function's parse); with this, equal; core-test filtered on jj (Debug tui) 55/55
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/edit.zig')
| -rw-r--r-- | core/edit.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/edit.zig b/core/edit.zig index 3517fe80..0b08dc9e 100644 --- a/core/edit.zig +++ b/core/edit.zig @@ -775,7 +775,10 @@ fn treeIndent(e: Editor, t: *Text, text: []const u8, row: usize, at: usize) Erro 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; - return indents.forNewline(e.scratch, l, tree, text, row, at); + // The tree is of the file's text, in its lines and offsets (the + // `Changes` layer's lines are none of it). + if (f.read_only.len == 0) return indents.forNewline(e.scratch, l, tree, text, row, at); + return indents.forNewline(e.scratch, l, tree, try panes.File.fileText(f, e.scratch), panes.File.fileRow(f, row), panes.File.fileOffset(f, at)); } /// helix's default auto-pairs (auto_pairs.rs DEFAULT_PAIRS): `o` opens one @@ -1970,8 +1973,8 @@ pub fn textobjectSelect(e: Editor, t: *Text, text: []const u8, obj: u21, around: }; if (object) |o| { const tree = normal.nodeTree(e, t, text) orelse return; - const s = syntax.objectAt(tree.path, tree.root, text, o, around, modal.selectionCursor(text, range)) orelse return; - return t.setRange(e.tab, text, 0, .{ .anchor = s.from, .head = s.to }, false); + const s = syntax.objectAt(tree.path, tree.root, tree.text, o, around, tree.in(modal.selectionCursor(text, range))) orelse return; + return t.setRange(e.tab, text, 0, .{ .anchor = tree.out(s.from, false), .head = tree.out(s.to, s.to > s.from) }, false); } switch (obj) { 'w', 'W' => { |
