File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,21 @@ impl LanguageServer for DjangoLanguageServer {
208
208
. await ;
209
209
}
210
210
211
+ async fn did_save ( & self , params : lsp_types:: DidSaveTextDocumentParams ) {
212
+ tracing:: info!( "Saved document: {:?}" , params. text_document. uri) ;
213
+
214
+ self . with_session_mut ( |session| {
215
+ let Some ( url) =
216
+ paths:: parse_lsp_uri ( & params. text_document . uri , paths:: LspContext :: DidSave )
217
+ else {
218
+ return ;
219
+ } ;
220
+
221
+ session. save_document ( & url) ;
222
+ } )
223
+ . await ;
224
+ }
225
+
211
226
async fn did_change ( & self , params : lsp_types:: DidChangeTextDocumentParams ) {
212
227
tracing:: info!( "Changed document: {:?}" , params. text_document. uri) ;
213
228
Original file line number Diff line number Diff line change @@ -172,6 +172,17 @@ impl Session {
172
172
}
173
173
}
174
174
175
+ pub fn save_document ( & mut self , url : & Url ) {
176
+ // Touch file in database to trigger re-analysis
177
+ if let Some ( path) = paths:: url_to_path ( url) {
178
+ self . with_db_mut ( |db| {
179
+ if db. has_file ( & path) {
180
+ db. touch_file ( & path) ;
181
+ }
182
+ } ) ;
183
+ }
184
+ }
185
+
175
186
/// Close a document.
176
187
///
177
188
/// Removes from workspace buffers and triggers database invalidation to fall back to disk.
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ pub enum LspContext {
42
42
DidChange ,
43
43
/// textDocument/didClose notification
44
44
DidClose ,
45
+ /// textDocument/didSave notification
46
+ DidSave ,
45
47
/// textDocument/completion request
46
48
Completion ,
47
49
}
@@ -52,6 +54,7 @@ impl std::fmt::Display for LspContext {
52
54
Self :: DidOpen => write ! ( f, "didOpen" ) ,
53
55
Self :: DidChange => write ! ( f, "didChange" ) ,
54
56
Self :: DidClose => write ! ( f, "didClose" ) ,
57
+ Self :: DidSave => write ! ( f, "didSave" ) ,
55
58
Self :: Completion => write ! ( f, "completion" ) ,
56
59
}
57
60
}
You can’t perform that action at this time.
0 commit comments