From a24d361ed16861d02ae67f91c908e224baf0cb3c Mon Sep 17 00:00:00 2001 From: Arend van Beelen jr Date: Thu, 11 Jul 2024 20:08:40 +0200 Subject: [PATCH] fix(grit): correct calculation of line and column numbers (#3409) --- .../biome_grit_patterns/src/grit_binding.rs | 2 +- .../tests/specs/ts/identifier.snap | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/biome_grit_patterns/src/grit_binding.rs b/crates/biome_grit_patterns/src/grit_binding.rs index 5ce7ced6875f..b4c914024225 100644 --- a/crates/biome_grit_patterns/src/grit_binding.rs +++ b/crates/biome_grit_patterns/src/grit_binding.rs @@ -69,7 +69,7 @@ impl<'a> Binding<'a, GritQueryContext> for GritBinding<'a> { match self { Self::Node(node) => { let source = SourceFile::new(SourceCode { - text: node.text(), + text: node.source(), line_starts: None, }); source.to_grit_range(node.text_trimmed_range()) diff --git a/crates/biome_grit_patterns/tests/specs/ts/identifier.snap b/crates/biome_grit_patterns/tests/specs/ts/identifier.snap index e1f3e5a60865..34ad9d08803d 100644 --- a/crates/biome_grit_patterns/tests/specs/ts/identifier.snap +++ b/crates/biome_grit_patterns/tests/specs/ts/identifier.snap @@ -7,36 +7,36 @@ SnapshotResult { matched_ranges: [ Range { start: Position { - line: 1, - column: 4, + line: 3, + column: 8, }, end: Position { - line: 1, - column: 4, + line: 3, + column: 11, }, start_byte: 25, end_byte: 28, }, Range { start: Position { - line: 1, - column: 4, + line: 6, + column: 3, }, end: Position { - line: 1, - column: 4, + line: 6, + column: 6, }, start_byte: 52, end_byte: 55, }, Range { start: Position { - line: 1, - column: 4, + line: 11, + column: 2, }, end: Position { - line: 1, - column: 4, + line: 11, + column: 5, }, start_byte: 99, end_byte: 102,