summaryrefslogtreecommitdiff
path: root/core/edit.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/edit.zig')
-rw-r--r--core/edit.zig9
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' => {