aboutsummaryrefslogtreecommitdiffstats
path: root/tests/query
diff options
context:
space:
mode:
authorLev Velykoivanenko <velykoivanenko.lev@gmail.com>2025-10-26 17:25:42 +0100
committerGitHub <noreply@github.com>2025-10-26 09:25:42 -0700
commitc53bb10a71a04860758757b190620814b4993a77 (patch)
tree8390c77671b682894d42f5fe374f5f92552d0f80 /tests/query
parentfeat(parsers): update c3, desktop, dot, gomod, idl, julia, kitty, matlab, mli... (diff)
downloadnvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar.gz
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar.bz2
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar.lz
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar.xz
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.tar.zst
nvim-treesitter-c53bb10a71a04860758757b190620814b4993a77.zip
fix(python): regex injection not working for concatenated strings (#8197)
Co-authored-by: Riley Bruins <ribru17@hotmail.com>
Diffstat (limited to 'tests/query')
-rw-r--r--tests/query/highlights/python/regex.py19
-rw-r--r--tests/query/highlights/starlark/test.bzl11
-rw-r--r--tests/query/injections/python/test.py18
-rw-r--r--tests/query/injections/starlark/test.bzl5
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/query/highlights/python/regex.py b/tests/query/highlights/python/regex.py
new file mode 100644
index 000000000..385ec7760
--- /dev/null
+++ b/tests/query/highlights/python/regex.py
@@ -0,0 +1,19 @@
+import re
+
+re_test = re.compile(r"^(?P<year>\d{4}) (?P<day>\d) \w\s{,3}$")
+# ^ @string.regexp
+re_test = re.compile(
+ # comment
+ # ^ @comment
+ r"^(?P<year>\d{4}){1}"
+ # ^ @string.regexp
+ # comment
+ # ^ @comment
+ r"(?P<day>\d) \w\s{,3}"
+ # ^ @string.regexp
+ # comment
+ # ^ @comment
+)
+# interpolation
+print("foo %s bar %d" % ("arg1", 2))
+# ^ @character
diff --git a/tests/query/highlights/starlark/test.bzl b/tests/query/highlights/starlark/test.bzl
new file mode 100644
index 000000000..88251f615
--- /dev/null
+++ b/tests/query/highlights/starlark/test.bzl
@@ -0,0 +1,11 @@
+# split
+# ^ @comment
+assert_eq('foo bar'.split(' '), ['foo', 'bar'])
+# ^ @keyword
+# ^ @punctuation.bracket
+# ^ @string
+# ^ @punctuation.delimiter
+assert_eq('foo bar foo'.rsplit(' ', 1), ['foo bar', 'foo'])
+# ^ @number
+assert_eq("foo %s bar %d" % ("arg1", 2), "foo arg1 bar 2")
+# ^ @character
diff --git a/tests/query/injections/python/test.py b/tests/query/injections/python/test.py
new file mode 100644
index 000000000..1d6a0a465
--- /dev/null
+++ b/tests/query/injections/python/test.py
@@ -0,0 +1,18 @@
+import re
+
+re_test = re.compile(r"^(?P<year>\d{4}) (?P<day>\d) \w\s{,3}$")
+# ^ @regex
+re_test = re.compile(
+ # comment
+ # ^ @comment
+ r"^(?P<year>\d{4}) "
+ # comment
+ # ^ @comment
+ r"(?P<day>\d) \w\s{,3}$"
+ # ^ @regex
+ # comment
+ # comment
+ # ^ @comment
+)
+print("foo %s bar %d" % ("arg1", 2))
+# ^ @printf
diff --git a/tests/query/injections/starlark/test.bzl b/tests/query/injections/starlark/test.bzl
new file mode 100644
index 000000000..4a8af5172
--- /dev/null
+++ b/tests/query/injections/starlark/test.bzl
@@ -0,0 +1,5 @@
+# split
+# ^ @comment
+assert_eq('foo bar'.split(' '), ['foo', 'bar'])
+assert_eq("foo %s bar %d" % ("arg1", 2), "foo arg1 bar 2")
+# ^ @printf