mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00
Fix LSP show message macro to allow format args (#15487)
## Summary This PR fixes the `show_*_msg` macros to pass all the tokens instead of just a single token. This allows for using various expressions right in the macro similar to how it would be in `format_args!`. ## Test Plan `cargo clippy`
This commit is contained in:
parent
18d5dbfb7f
commit
6aef4ad008
3 changed files with 10 additions and 11 deletions
|
@ -40,7 +40,7 @@ pub(super) fn try_show_message(
|
|||
/// Sends an error to the client with a formatted message. The error is sent in a
|
||||
/// `window/showMessage` notification.
|
||||
macro_rules! show_err_msg {
|
||||
($msg:expr$(, $($arg:tt),*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg, $($($arg),*)?).to_string(), lsp_types::MessageType::ERROR)
|
||||
($msg:expr$(, $($arg:tt)*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg$(, $($arg)*)?).to_string(), lsp_types::MessageType::ERROR)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -40,15 +40,15 @@ pub(super) fn try_show_message(
|
|||
/// Sends a request to display an error to the client with a formatted message. The error is sent
|
||||
/// in a `window/showMessage` notification.
|
||||
macro_rules! show_err_msg {
|
||||
($msg:expr$(, $($arg:tt),*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg, $($($arg),*)?).to_string(), lsp_types::MessageType::ERROR)
|
||||
($msg:expr$(, $($arg:tt)*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg$(, $($arg)*)?).to_string(), lsp_types::MessageType::ERROR)
|
||||
};
|
||||
}
|
||||
|
||||
/// Sends a request to display a warning to the client with a formatted message. The warning is
|
||||
/// sent in a `window/showMessage` notification.
|
||||
macro_rules! show_warn_msg {
|
||||
($msg:expr$(, $($arg:tt),*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg, $($($arg),*)?).to_string(), lsp_types::MessageType::WARNING)
|
||||
($msg:expr$(, $($arg:tt)*)?) => {
|
||||
crate::message::show_message(::core::format_args!($msg$(, $($arg)*)?).to_string(), lsp_types::MessageType::WARNING)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -186,10 +186,9 @@ impl RuffSettingsIndex {
|
|||
// means for different editors.
|
||||
if is_default_workspace {
|
||||
if has_error {
|
||||
let root = root.display();
|
||||
show_err_msg!(
|
||||
"Error while resolving settings from workspace {root}. \
|
||||
Please refer to the logs for more details.",
|
||||
"Error while resolving settings from workspace {}. Please refer to the logs for more details.",
|
||||
root.display()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -300,9 +299,9 @@ impl RuffSettingsIndex {
|
|||
});
|
||||
|
||||
if has_error.load(Ordering::Relaxed) {
|
||||
let root = root.display();
|
||||
show_err_msg!(
|
||||
"Error while resolving settings from workspace {root}. Please refer to the logs for more details.",
|
||||
"Error while resolving settings from workspace {}. Please refer to the logs for more details.",
|
||||
root.display()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue