fix(editor): restore python auto-indent by removing custom ipython indent service#727
Merged
fix(editor): restore python auto-indent by removing custom ipython indent service#727
Conversation
…dent service When IPython magic support (%%html, %%bash, etc.) was added, a custom indent service was included to prevent indentation after magic lines. However, this broke standard Python indentation — pressing Enter after "class Thing:" or "def foo():" no longer indented the next line. The custom service was returning null to fall back to Python's tree-based indentation, but this fallback wasn't working correctly. Rather than trying to calculate indentation manually (error-prone), we now rely entirely on CodeMirror's Python indentation logic. Trade-off: Magic lines may now indent when they shouldn't, but this is preferable to breaking regular Python code indentation.
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.
When IPython magic support (%%html, %%bash, etc.) was added, a custom indent service was included to prevent indentation after magic lines. However, this broke standard Python indentation — pressing Enter after "class Thing:" or "def foo():" no longer indented the next line.
The custom service attempted to fall back to CodeMirror's Python indentation by returning null, but this fallback wasn't working correctly. Rather than trying to calculate indentation manually (error-prone), we now rely entirely on CodeMirror's Python indentation logic.
Trade-off: Magic lines may now indent when they shouldn't, but this is preferable to breaking regular Python code indentation.
Verification
class Thing:+ Enter → next line is indented 4 spacesdef foo():+ Enter → next line is indented 4 spacesif True:+ Enter → next line is indented 4 spacesfor i in range(10):+ Enter → indents furtherPR submitted by @rgbkrk's agent, Quill