mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 04:40:08 -04:00
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.
This commit is contained in:
parent
2497714755
commit
7248feaca4
2 changed files with 23 additions and 6 deletions
|
|
@ -3,7 +3,12 @@
|
||||||
object: (identifier) @_re)
|
object: (identifier) @_re)
|
||||||
arguments: (argument_list
|
arguments: (argument_list
|
||||||
(string
|
(string
|
||||||
(string_content) @injection.content))
|
(string_start)
|
||||||
|
[
|
||||||
|
(string_content) @injection.content
|
||||||
|
(interpolation)
|
||||||
|
]+
|
||||||
|
(string_end)))
|
||||||
(#eq? @_re "re")
|
(#eq? @_re "re")
|
||||||
(#set! injection.language "regex"))
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
|
@ -12,11 +17,13 @@
|
||||||
object: (identifier) @_re)
|
object: (identifier) @_re)
|
||||||
arguments: (argument_list
|
arguments: (argument_list
|
||||||
(concatenated_string
|
(concatenated_string
|
||||||
[
|
(string
|
||||||
(string
|
(string_start)
|
||||||
(string_content) @injection.content)
|
[
|
||||||
(comment)
|
(string_content) @injection.content
|
||||||
]+))
|
(interpolation)
|
||||||
|
]+
|
||||||
|
(string_end))))
|
||||||
(#eq? @_re "re")
|
(#eq? @_re "re")
|
||||||
(#set! injection.language "regex"))
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,15 @@ re_test = re.compile(
|
||||||
# comment
|
# comment
|
||||||
# ^ @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))
|
print("foo %s bar %d" % ("arg1", 2))
|
||||||
# ^ @printf
|
# ^ @printf
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue