Skip to content

Commit

Permalink
fix(lsp): remove closed documents from the state
Browse files Browse the repository at this point in the history
To avoid growing the list of open files indefinitely, remove them from
the state of the server when closed in the editor.
  • Loading branch information
dnaka91 committed Dec 4, 2023
1 parent 80d3c5f commit a84018c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/stef-lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use tower_lsp::{
jsonrpc::Result,
lsp_types::{
ConfigurationItem, Diagnostic, DidChangeConfigurationParams, DidChangeTextDocumentParams,
DidOpenTextDocumentParams, InitializeParams, InitializeResult, InitializedParams,
MessageType, Registration, SemanticTokenModifier, SemanticTokenType,
DidCloseTextDocumentParams, DidOpenTextDocumentParams, InitializeParams, InitializeResult,
InitializedParams, MessageType, Registration, SemanticTokenModifier, SemanticTokenType,
SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions,
SemanticTokensParams, SemanticTokensResult, SemanticTokensServerCapabilities,
ServerCapabilities, ServerInfo, TextDocumentSyncCapability, TextDocumentSyncKind, Url,
Expand Down Expand Up @@ -207,6 +207,11 @@ impl LanguageServer for Backend {
.insert(params.text_document.uri, file);
}

async fn did_close(&self, params: DidCloseTextDocumentParams) {
debug!(uri = %params.text_document.uri, "schema closed");
self.files.lock().await.remove(&params.text_document.uri);
}

async fn semantic_tokens_full(
&self,
params: SemanticTokensParams,
Expand Down

0 comments on commit a84018c

Please sign in to comment.