Closes #26157 This fixes multiple cases where Python indentation breaks: - [x] Adding a new line after `if`, `try`, etc. correctly indents in that scope - [x] Multi-cursor tabs correctly preserve relative indents - [x] Adding a new line after `else`, `finally`, etc. correctly outdents them - [x] Existing Tests Future Todo: I need to add new tests for all the above cases. Before/After: 1. Multi-cursor tabs correctly preserve relative indents https://github.com/user-attachments/assets/08a46ddf-5371-4e26-ae7d-f8aa0b31c4a2 2. Adding a new line after `if`, `try`, etc. correctly indents in that scope https://github.com/user-attachments/assets/9affae97-1a50-43c9-9e9f-c1ea3a747813 Release Notes: - Fixes indentation-related issues involving tab, newline, etc for Python.
34 lines
2.1 KiB
TOML
34 lines
2.1 KiB
TOML
name = "Python"
|
|
grammar = "python"
|
|
path_suffixes = ["py", "pyi", "mpy"]
|
|
first_line_pattern = '^#!.*\bpython[0-9.]*\b'
|
|
line_comments = ["# "]
|
|
autoclose_before = ";:.,=}])>"
|
|
brackets = [
|
|
{ start = "f\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "f'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "b\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "b'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "u\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "u'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "r\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "r'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "rb\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "rb'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "t\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "t'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
|
{ start = "\"\"\"", end = "\"\"\"", close = true, newline = false, not_in = ["string"] },
|
|
{ start = "'''", end = "'''", close = true, newline = false, not_in = ["string"] },
|
|
{ start = "{", end = "}", close = true, newline = true },
|
|
{ start = "[", end = "]", close = true, newline = true },
|
|
{ start = "(", end = ")", close = true, newline = true },
|
|
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
|
{ start = "'", end = "'", close = true, newline = false, not_in = ["string"] },
|
|
]
|
|
|
|
auto_indent_using_last_non_empty_line = false
|
|
debuggers = ["Debugpy"]
|
|
significant_indentation = true
|
|
increase_indent_pattern = "^\\s*(try)\\b.*:"
|
|
decrease_indent_pattern = "^\\s*(else|elif|except|finally)\\b.*:"
|