-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range formatting support #373
Conversation
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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:offset
I 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
textSelector
but 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