language: Fix indent suggestions for significant indented languages like Python (#29625)
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.
This commit is contained in:
parent
22ad207baf
commit
7c76cee16d
5 changed files with 84 additions and 34 deletions
|
@ -1209,7 +1209,7 @@ mod tests {
|
|||
append(&mut buffer, "foo(\n1)", cx);
|
||||
assert_eq!(
|
||||
buffer.text(),
|
||||
"def a():\n \n if a:\n b()\n else:\n foo(\n 1)"
|
||||
"def a():\n \n if a:\n b()\n else:\n foo(\n 1)"
|
||||
);
|
||||
|
||||
// dedent the closing paren if it is shifted to the beginning of the line
|
||||
|
@ -1255,7 +1255,7 @@ mod tests {
|
|||
|
||||
// dedent "else" on the line after a closing paren
|
||||
append(&mut buffer, "\n else:\n", cx);
|
||||
assert_eq!(buffer.text(), "if a:\n b(\n )\nelse:\n ");
|
||||
assert_eq!(buffer.text(), "if a:\n b(\n )\nelse:\n");
|
||||
|
||||
buffer
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue