mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(python): add break/continue dedent
This commit is contained in:
parent
1ffa019856
commit
c9ef5e58f7
3 changed files with 16 additions and 0 deletions
|
|
@ -78,6 +78,11 @@
|
|||
|
||||
(ERROR "{" @indent.align (#set! indent.open_delimiter "{") (#set! indent.close_delimiter "}") . (_))
|
||||
|
||||
[
|
||||
(break_statement)
|
||||
(continue_statement)
|
||||
] @indent.dedent
|
||||
|
||||
(parenthesized_expression ")" @indent.end)
|
||||
(generator_expression ")" @indent.end)
|
||||
(list_comprehension "]" @indent.end)
|
||||
|
|
|
|||
9
tests/indent/python/break_continue.py
Normal file
9
tests/indent/python/break_continue.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def f():
|
||||
for x in range(1, 2):
|
||||
if x == 1:
|
||||
break
|
||||
|
||||
def f():
|
||||
for x in range(1, 2):
|
||||
if x == 1:
|
||||
continue
|
||||
|
|
@ -88,6 +88,8 @@ describe("indent Python:", function()
|
|||
run:new_line("match_case.py", { on_line = 5, text = "pass", indent = 12 })
|
||||
run:new_line("match_case.py", { on_line = 10, text = "pass", indent = 8 })
|
||||
run:new_line("match_case.py", { on_line = 15, text = "pass", indent = 12 })
|
||||
run:new_line("break_continue.py", { on_line = 4, text = "pass", indent = 8 })
|
||||
run:new_line("break_continue.py", { on_line = 9, text = "pass", indent = 8 })
|
||||
|
||||
for _, line in ipairs { 2, 5, 8, 11, 16, 21, 24, 27, 34, 39 } do
|
||||
run:new_line("return_dedent.py", { on_line = line, text = "x", indent = 0 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue