This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Conversation
AlexWaygood
reviewed
Jan 31, 2024
charliermarsh
approved these changes
Jan 31, 2024
dhruvmanila
approved these changes
Feb 1, 2024
Comment on lines
+1229
to
+1257
| # We don't support range formatting of notebooks yet but VS Code | ||
| # doesn't seem to respect the document filter. For now, format the entire cell. | ||
| range = None if document.kind is DocumentKind.Cell else range |
Member
There was a problem hiding this comment.
This is unfortunate because as a user I wouldn't expect that "Format selection" in Jupyter notebook would format an entire cell. I'm not sure what the right solution is but I'd prefer to send a info / warning message to the user stating that range formatting isn't yet supported for Jupyter Notebooks instead.
Member
Author
There was a problem hiding this comment.
I agree but I wasn't able to come up with something better. I'm worried that a warning would be rather annoying and force users to change their setting from modificationsIfAvailable to the entire document or they get annoyed by the warning on every save
0490f62 to
6d6c849
Compare
6d6c849 to
43499c5
Compare
0f16d4f to
3b59a36
Compare
3d3ecda to
7431410
Compare
7431410 to
49b9db7
Compare
This was referenced Apr 2, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR implements support for range formatting for Python files. It requires astral-sh/ruff#9733
Note to myself: Writing Python is hard 😅
Closes #116
Closes astral-sh/ruff-vscode#319
Limitations
Range formatting Notebooks isn't supported because it raises a few interesting questions:
cell:offsetI feel like implementing range formatting will be straightforward with a Rust LSP because:
I tried to teach VS Code that Range formatting isn't supported for notebooks by using a
textSelectorbut VS code doesn't seem to care :(That's why the implementation defaults to format the entire cell for now. I'm open to suggestions.
Test Plan
Screencast from 2024-01-31 16-11-40.webm