Skip to content

Commit

Permalink
Fix LSP show message macro to allow format args
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Jan 15, 2025
1 parent a2dc8c9 commit 49863f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions crates/red_knot_server/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
}
8 changes: 4 additions & 4 deletions crates/ruff_server/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
}
9 changes: 4 additions & 5 deletions crates/ruff_server/src/session/index/ruff_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

Expand Down Expand Up @@ -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()
);
}

Expand Down

0 comments on commit 49863f7

Please sign in to comment.