Support indent regex with inline comments in Python (#37903)
Closes #36491 This issue is caused by the Python language configuration treating compound statements (such as for loops and if statements) that end with an inline comment as not requiring an increased indent. Release Notes: - python: Correctly indent lines starting the blocks (for, finally, if, else, try) that have trailing comments.
This commit is contained in:
@@ -28,10 +28,10 @@ brackets = [
|
||||
|
||||
auto_indent_using_last_non_empty_line = false
|
||||
debuggers = ["Debugpy"]
|
||||
increase_indent_pattern = "^[^#].*:\\s*$"
|
||||
increase_indent_pattern = "^[^#].*:\\s*(#.*)?$"
|
||||
decrease_indent_patterns = [
|
||||
{ pattern = "^\\s*elif\\b.*:", valid_after = ["if", "elif"] },
|
||||
{ pattern = "^\\s*else\\b.*:", valid_after = ["if", "elif", "for", "while", "except"] },
|
||||
{ pattern = "^\\s*except\\b.*:", valid_after = ["try", "except"] },
|
||||
{ pattern = "^\\s*finally\\b.*:", valid_after = ["try", "except", "else"] },
|
||||
{ pattern = "^\\s*elif\\b.*:\\s*(#.*)?", valid_after = ["if", "elif"] },
|
||||
{ pattern = "^\\s*else\\b.*:\\s*(#.*)?", valid_after = ["if", "elif", "for", "while", "except"] },
|
||||
{ pattern = "^\\s*except\\b.*:\\s*(#.*)?", valid_after = ["try", "except"] },
|
||||
{ pattern = "^\\s*finally\\b.*:\\s*(#.*)?", valid_after = ["try", "except", "else"] },
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user