feat(editor): add language-aware autoindent - #184
Merged
Conversation
fcoury
force-pushed
the
feature/language-aware-autoindent
branch
from
August 13, 2026 03:35
7152afe to
62fc1e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Red previously copied the current line's whitespace when opening or splitting lines, without considering the active language. In Python, that left users manually indenting suites and continuations, dedenting branch and stop statements, and removing automatic indentation one character at a time.
What Changed
o, andO, and reindent Python branch headers as their trigger text is completed.How to Test
def something(x):, and press Enter. Expect the next line to begin at four columns. Typereturn xand press Enter again; expect the new line to dedent to column zero.values = [, useo, and expect an eight-column hanging indent. Press Backspace twice and expect the cursor to move first to column four and then column zero.value = "note:"orvalue = 1 # note:. Expect no extra indentation. Open an automatically indented blank line and press Escape; expect no trailing whitespace to remain.cargo test python_enter_indents_a_suite_and_dedents_after_returnandcargo test backspace_uses_soft_tab_stops_inside_leading_indentation; expect both targeted regressions to pass.