mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
ruff server
: Improve error message when a command is run on an unavailable document (#11823)
## Summary
Fixes #11744.
We now show a distinct popup message when we fail to get a document
snapshot during command execution. This message more clearly
communicates the issue to the user, instead of a generic "ruff
encountered an error" message.
## Test Plan
Try running `Fix all auto-fixable problems` on an incompatible file (for
example: `settings.json`). You should see the following popup message:
<img width="456" alt="Screenshot 2024-06-11 at 11 47 16 AM"
src="3a28e3d7
-3896-4dd0-b117-f87300dd3b68">
This commit is contained in:
parent
4e9d771aa0
commit
7d5cf1811b
1 changed files with 5 additions and 4 deletions
|
@ -68,10 +68,11 @@ impl super::SyncRequestHandler for ExecuteCommand {
|
|||
|
||||
let mut edit_tracker = WorkspaceEditTracker::new(session.resolved_client_capabilities());
|
||||
for Argument { uri, version } in arguments {
|
||||
let snapshot = session
|
||||
.take_snapshot(uri.clone())
|
||||
.ok_or(anyhow::anyhow!("Document snapshot not available for {uri}",))
|
||||
.with_failure_code(ErrorCode::InternalError)?;
|
||||
let Some(snapshot) = session.take_snapshot(uri.clone()) else {
|
||||
tracing::error!("Document at {uri} could not be opened");
|
||||
show_err_msg!("Ruff does not recognize this file");
|
||||
return Ok(None);
|
||||
};
|
||||
match command {
|
||||
Command::FixAll => {
|
||||
let fixes = super::code_action_resolve::fix_all_edit(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue