summaryrefslogtreecommitdiff
path: root/src/syntax.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax.zig')
-rw-r--r--src/syntax.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/syntax.zig b/src/syntax.zig
index 3a83800b..4494945f 100644
--- a/src/syntax.zig
+++ b/src/syntax.zig
@@ -475,7 +475,10 @@ fn matchSpan(q: *const ts.Query, match: anytype, capture: u32, text: []const u8)
const s: Span = .{ .from = c.node.startByte(), .to = c.node.endByte() };
span = if (span) |old| .{ .from = @min(old.from, s.from), .to = @max(old.to, s.to) } else s;
};
- const found = span orelse return null;
+ var found = span orelse return null;
+ // a node that takes its line's newline (this zig grammar's comments)
+ // is the line without it, as helix's grammars have it
+ if (found.to > found.from + 1 and found.to <= text.len and text[found.to - 1] == '\n') found.to -= 1;
const steps = q.predicatesForPattern(match.pattern_index);
var i: usize = 0;
while (i < steps.len) {