@@ -31,12 +31,10 @@ impl Backend {
3131 }
3232
3333 fn upsert_document ( & self , doc : Arc < TextDocumentItem > ) {
34- let uri = doc. uri . clone ( ) ;
3534 self . documents
3635 . write ( )
3736 . unwrap ( )
38- . get_mut ( & uri)
39- . map ( |old| std:: mem:: replace ( old, doc. clone ( ) ) ) ;
37+ . insert ( doc. uri . clone ( ) , doc. clone ( ) ) ;
4038 }
4139
4240 fn get_document ( & self , uri : & Url ) -> Option < Arc < TextDocumentItem > > {
@@ -105,7 +103,6 @@ impl Backend {
105103 }
106104
107105 async fn clear_diagnostics ( & self , uri : & Url ) {
108- self . diagnostics . write ( ) . unwrap ( ) . remove ( uri) ;
109106 self . client
110107 . publish_diagnostics ( uri. clone ( ) , vec ! [ ] , None )
111108 . await ;
@@ -263,14 +260,14 @@ impl LanguageServer for Backend {
263260 return ;
264261 }
265262
266- self . client
267- . log_message ( MessageType :: INFO , format ! ( "did_change {}\n " , uri) )
268- . await ;
269-
270263 assert_eq ! ( content_changes. len( ) , 1 ) ;
271264 let change = content_changes. into_iter ( ) . next ( ) . unwrap ( ) ;
272265 assert ! ( change. range. is_none( ) ) ;
273266
267+ self . client
268+ . log_message ( MessageType :: INFO , format ! ( "did_change {}" , uri) )
269+ . await ;
270+
274271 let updated_doc =
275272 TextDocumentItem :: new ( uri. clone ( ) , "" . to_string ( ) , version, change. text . clone ( ) ) ;
276273 self . upsert_document ( Arc :: new ( updated_doc. clone ( ) ) ) ;
@@ -316,7 +313,13 @@ impl LanguageServer for Backend {
316313 self . clear_diagnostics ( & text_document. uri ) . await ;
317314 let input = document. text . as_str ( ) ;
318315
316+ self . client
317+ . log_message ( MessageType :: INFO , format ! ( "before: {}" , input) )
318+ . await ;
319319 let result = autocorrect:: format_for ( input, document. uri . path ( ) ) ;
320+ self . client
321+ . log_message ( MessageType :: INFO , format ! ( "after: {}" , result. out) )
322+ . await ;
320323 let range = Range :: new (
321324 Position :: new ( 0 , 0 ) ,
322325 Position {
0 commit comments