summaryrefslogtreecommitdiff
path: root/core/syntax.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/syntax.zig')
-rw-r--r--core/syntax.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/syntax.zig b/core/syntax.zig
index 08ea1fb4..a388573b 100644
--- a/core/syntax.zig
+++ b/core/syntax.zig
@@ -566,7 +566,7 @@ pub fn objectAt(path: []const u8, tree_ptr: *anyopaque, text: []const u8, object
/// `]f`/`[f` and kin: the next object starting after byte `at`, or the
/// previous one ending before it (helix goto_treesitter_object), from the
/// first of `.movement`, `.around`, `.inside` the query names.
-pub fn objectNext(path: []const u8, tree_ptr: *anyopaque, text: []const u8, object: Object, forward: bool, at: usize) ?Span {
+pub fn objectNext(path: []const u8, tree_ptr: *anyopaque, text: []const u8, object: Object, forward: bool, at: usize, within: ?[2]usize) ?Span {
const q = objectQuery(path) orelse return null;
var buf: [32]u8 = undefined;
const capture = for ([_][]const u8{ "movement", "around", "inside" }) |kind| {
@@ -576,6 +576,9 @@ pub fn objectNext(path: []const u8, tree_ptr: *anyopaque, text: []const u8, obje
const tree: *const ts.Tree = @ptrCast(@alignCast(tree_ptr));
const cursor = ts.QueryCursor.create();
defer cursor.destroy();
+ // Only the objects these bytes hold (a body's rows shown): its painted
+ // targets (body_layer.paintTargets).
+ if (within) |w| cursor.setByteRange(@intCast(w[0]), @intCast(w[1])) catch return null;
cursor.exec(q, tree.rootNode());
var best: ?Span = null;
while (cursor.nextMatch()) |match| {