diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2026-07-20 00:29:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-20 00:29:57 +0200 |
| commit | 7248feaca45e4d944591497964bc19afa89ad1c6 (patch) | |
| tree | 9f6e9dba29fcea8e31b859657c13bffafc949f18 | |
| parent | bot(parsers): update inko (diff) | |
| download | nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar.gz nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar.bz2 nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar.lz nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar.xz nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.tar.zst nvim-treesitter-7248feaca45e4d944591497964bc19afa89ad1c6.zip | |
fix(python): improve f-string injections (#8644)
Problem: Neovim removed match limits, which can lead to catastrophic performance with injection queries.
Solution: Tighten up f-string injections.
| -rw-r--r-- | runtime/queries/python/injections.scm | 19 | ||||
| -rw-r--r-- | tests/query/injections/python/test.py | 10 |
2 files changed, 23 insertions, 6 deletions
diff --git a/runtime/queries/python/injections.scm b/runtime/queries/python/injections.scm index 2a120d9b5..28334477c 100644 --- a/runtime/queries/python/injections.scm +++ b/runtime/queries/python/injections.scm @@ -3,7 +3,12 @@ object: (identifier) @_re) arguments: (argument_list (string - (string_content) @injection.content)) + (string_start) + [ + (string_content) @injection.content + (interpolation) + ]+ + (string_end))) (#eq? @_re "re") (#set! injection.language "regex")) @@ -12,11 +17,13 @@ object: (identifier) @_re) arguments: (argument_list (concatenated_string - [ - (string - (string_content) @injection.content) - (comment) - ]+)) + (string + (string_start) + [ + (string_content) @injection.content + (interpolation) + ]+ + (string_end)))) (#eq? @_re "re") (#set! injection.language "regex")) diff --git a/tests/query/injections/python/test.py b/tests/query/injections/python/test.py index 1d6a0a465..f6dbaf355 100644 --- a/tests/query/injections/python/test.py +++ b/tests/query/injections/python/test.py @@ -14,5 +14,15 @@ re_test = re.compile( # comment # ^ @comment ) +a.a( + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" + f"<td class=\"a{a}\">{a}</td>" +) print("foo %s bar %d" % ("arg1", 2)) # ^ @printf |
