mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
Ignore source code actions for a notebook cell (#16154)
## Summary Related to https://github.com/astral-sh/ruff-vscode/pull/686, this PR ignores handling source code actions for notebooks which are not prefixed with `notebook`. The main motivation is that the native server does not actually handle it well which results in gibberish code. There's some context about this in https://github.com/astral-sh/ruff-vscode/issues/680#issuecomment-2647490812 and the following comments. closes: https://github.com/astral-sh/ruff-vscode/issues/680 ## Test Plan Running a notebook with the following does nothing except log the message: ```json "notebook.codeActionsOnSave": { "source.organizeImports.ruff": "explicit", }, ``` while, including the `notebook` code actions does make the edit (as usual): ```json "notebook.codeActionsOnSave": { "notebook.source.organizeImports.ruff": "explicit" }, ```
This commit is contained in:
parent
b5cd4f2f70
commit
82eae511ca
3 changed files with 48 additions and 3 deletions
|
@ -184,4 +184,15 @@ impl DocumentSnapshot {
|
|||
pub(crate) fn encoding(&self) -> PositionEncoding {
|
||||
self.position_encoding
|
||||
}
|
||||
|
||||
/// Returns `true` if this snapshot represents a notebook cell.
|
||||
pub(crate) const fn is_notebook_cell(&self) -> bool {
|
||||
matches!(
|
||||
&self.document_ref,
|
||||
index::DocumentQuery::Notebook {
|
||||
cell_url: Some(_),
|
||||
..
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue