diff --git a/crates/cairo-lang-language-server/src/server/routing/mod.rs b/crates/cairo-lang-language-server/src/server/routing/mod.rs index 125930d98aa..dd55f28ff0b 100644 --- a/crates/cairo-lang-language-server/src/server/routing/mod.rs +++ b/crates/cairo-lang-language-server/src/server/routing/mod.rs @@ -12,7 +12,7 @@ use lsp_server::{ErrorCode, ExtractError, Notification, Request, RequestId}; use lsp_types::notification::{ Cancel, DidChangeConfiguration, DidChangeTextDocument, DidChangeWatchedFiles, DidCloseTextDocument, DidOpenTextDocument, DidSaveTextDocument, - Notification as NotificationTrait, + Notification as NotificationTrait, SetTrace, }; use lsp_types::request::{ CodeActionRequest, Completion, ExecuteCommand, Formatting, GotoDefinition, HoverRequest, @@ -79,7 +79,6 @@ pub fn request<'a>(request: Request) -> Task<'a> { pub fn notification<'a>(notification: Notification) -> Task<'a> { match notification.method.as_str() { - Cancel::METHOD => local_notification_task::(notification), DidChangeTextDocument::METHOD => { local_notification_task::(notification) } @@ -94,6 +93,14 @@ pub fn notification<'a>(notification: Notification) -> Task<'a> { } DidOpenTextDocument::METHOD => local_notification_task::(notification), DidSaveTextDocument::METHOD => local_notification_task::(notification), + + // Ignoring $/cancelRequest because CairoLS does cancellation inside-out when the state is + // mutated, and we allow ourselves to ignore the corner case of user hitting ESC manually. + Cancel::METHOD => Ok(Task::nothing()), + + // Ignoring $/setTrace because CairoLS never emits $/logTrace notifications anyway. + SetTrace::METHOD => Ok(Task::nothing()), + method => { warn!("received notification {method} which does not have a handler"); diff --git a/crates/cairo-lang-language-server/src/server/routing/traits.rs b/crates/cairo-lang-language-server/src/server/routing/traits.rs index e9c925ed0d4..4ec426ecbb9 100644 --- a/crates/cairo-lang-language-server/src/server/routing/traits.rs +++ b/crates/cairo-lang-language-server/src/server/routing/traits.rs @@ -9,15 +9,15 @@ use cairo_lang_filesystem::db::{ AsFilesGroupMut, FilesGroup, FilesGroupEx, PrivRawFileContentQuery, }; use lsp_types::notification::{ - Cancel, DidChangeConfiguration, DidChangeTextDocument, DidChangeWatchedFiles, - DidCloseTextDocument, DidOpenTextDocument, DidSaveTextDocument, Notification, + DidChangeConfiguration, DidChangeTextDocument, DidChangeWatchedFiles, DidCloseTextDocument, + DidOpenTextDocument, DidSaveTextDocument, Notification, }; use lsp_types::request::{ CodeActionRequest, Completion, ExecuteCommand, Formatting, GotoDefinition, HoverRequest, Request, SemanticTokensFullRequest, }; use lsp_types::{ - CancelParams, CodeActionParams, CodeActionResponse, CompletionParams, CompletionResponse, + CodeActionParams, CodeActionResponse, CompletionParams, CompletionResponse, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWatchedFilesParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentFormattingParams, ExecuteCommandParams, GotoDefinitionParams, GotoDefinitionResponse, @@ -132,18 +132,6 @@ impl BackgroundDocumentRequestHandler for Formatting { } } -impl SyncNotificationHandler for Cancel { - #[tracing::instrument(name = "$/cancelRequest", skip_all)] - fn run( - _state: &mut State, - _notifier: Notifier, - _requester: &mut Requester<'_>, - _params: CancelParams, - ) -> LSPResult<()> { - Ok(()) - } -} - impl SyncNotificationHandler for DidChangeTextDocument { #[tracing::instrument( name = "textDocument/didChange",