Commit
Author: Riley Bruins [ribru17@hotmail.com]
Committer: Michael Davis [mcarsondavis@gmail.com] Mon, 13 May 2024 14:36:00 +0000
Hash: 8c4a9908ce67ea3f896983837e7a3ca2274a1820
Timestamp: Mon, 13 May 2024 14:36:00 +0000 (7 months ago)

+3 -2 +/-2 browse
Expose the similarity score as a named node
Expose the similarity score as a named node

It was previously a field, but a field is an impossible pattern for a
regex literal like we use for score. I.e.:

    (similarity score: _ @_some_capture_)

Cannot match and on recent tree-sitter versions will cause an error
during query analysis.
1diff --git a/grammar.js b/grammar.js
2index bc9e124..1ecb116 100644
3--- a/grammar.js
4+++ b/grammar.js
5 @@ -80,7 +80,7 @@ module.exports = grammar({
6
7 index: ($) => iseq("index", $.commit, "..", $.commit, optional($.mode)),
8
9- similarity: ($) => iseq("similarity", "index", field("score", /\d+/), "%"),
10+ similarity: ($) => iseq("similarity", "index", alias(/\d+/, $.score), "%"),
11
12 old_file: ($) => iseq("---", $.filename),
13 new_file: ($) => iseq("+++", $.filename),
14 diff --git a/test/corpus/text.txt b/test/corpus/text.txt
15index 2b82ef4..2f38814 100644
16--- a/test/corpus/text.txt
17+++ b/test/corpus/text.txt
18 @@ -101,7 +101,8 @@ rename to tmp.md
19 (command
20 (argument)
21 (filename))
22- (similarity)
23+ (similarity
24+ (score))
25 (file_change
26 (filename))
27 (file_change