-
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
Support notebook-scoped VS Code actions #351
Merged
Merged
Conversation
This file contains 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
charliermarsh
commented
Jan 5, 2024
): | ||
# Generate the "Ruff: Organize Imports" edit | ||
params.edit = await _fix_document_impl(document, only=["I001", "I002"]) | ||
|
||
elif settings["fixAll"] and params.kind in ( | ||
CodeActionKind.SourceFixAll, | ||
f"{CodeActionKind.SourceFixAll.value}.ruff", |
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'm pretty sure we only ever pass the full action here? This is for deferred actions.
charliermarsh
force-pushed
the
charlie/jupyter
branch
3 times, most recently
from
January 5, 2024 15:51
e9221a4
to
1c7c119
Compare
zanieb
reviewed
Jan 5, 2024
zanieb
reviewed
Jan 5, 2024
zanieb
reviewed
Jan 5, 2024
zanieb
approved these changes
Jan 5, 2024
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.
Sweet fix!
Merged
charliermarsh
added a commit
that referenced
this pull request
Jan 5, 2024
Separating out from #351.
charliermarsh
force-pushed
the
charlie/jupyter
branch
from
January 5, 2024 18:15
1c7c119
to
edfc355
Compare
azurelotus0926
added a commit
to azurelotus0926/ruff-lsp
that referenced
this pull request
Jun 27, 2024
Separating out from astral-sh/ruff-lsp#351.
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.
Summary
VS Code added support for
notebook.*
-scoped code actions (https://code.visualstudio.com/api/references/vscode-api#CodeActionKind), which are intended to run over the entire document, unlike the actions that omit thenotebook.
namespace, which instead only operate over individual cells. The latter are problematic for actions that need global context, e.g., our unused imports rules.When the
notebook.*
actions are triggered, VS Code sends down the first cell (see: microsoft/vscode#193120) as the URI. This PR adds handlers for the actions and logic to use the notebook, rather than the cell.Closes #320.
Test Plan
Used the following
settings.json
:Verified that imports used across cells were not removed (whereas
"source.fixAll": true
did cause imports to be removed).