mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
ruff server
: Important errors are now shown as popups (#10951)
## Summary
Fixes #10866.
Introduces the `show_err_msg!` macro which will send a message to be
shown as a popup to the client via the `window/showMessage` LSP method.
## Test Plan
Insert various `show_err_msg!` calls in common code paths (for example,
at the beginning of `event_loop`) and confirm that these messages appear
in your editor.
To test that panicking works correctly, add this to the top of the `fn
run` definition in
`crates/ruff_server/src/server/api/requests/execute_command.rs`:
```rust
panic!("This should appear");
```
Then, try running a command like `Ruff: Format document` from the
command palette (`Ctrl/Cmd+Shift+P`). You should see the following
messages appear:

This commit is contained in:
parent
eab3c4e334
commit
2882604451
6 changed files with 81 additions and 1 deletions
|
@ -30,6 +30,8 @@ mod api;
|
|||
mod client;
|
||||
mod schedule;
|
||||
|
||||
pub(crate) use client::ClientSender;
|
||||
|
||||
pub(crate) type Result<T> = std::result::Result<T, api::Error>;
|
||||
|
||||
pub struct Server {
|
||||
|
@ -44,6 +46,8 @@ impl Server {
|
|||
pub fn new(worker_threads: NonZeroUsize) -> crate::Result<Self> {
|
||||
let (conn, threads) = lsp::Connection::stdio();
|
||||
|
||||
crate::message::init_messenger(&conn.sender);
|
||||
|
||||
let (id, params) = conn.initialize_start()?;
|
||||
|
||||
let init_params: types::InitializeParams = serde_json::from_value(params)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue