@@ -31,7 +31,7 @@ struct DiagnosticData<'c> {
3131struct IgnoreInProjectCommandArguments {
3232 typo : String ,
3333 /// The configuration file that should be modified to ignore the typo
34- config_file_path : String ,
34+ config_file_path : PathBuf ,
3535}
3636
3737impl LanguageServer for Backend < ' static , ' static > {
@@ -225,35 +225,38 @@ impl LanguageServer for Backend<'static, 'static> {
225225 . router
226226 . at ( & uri_path)
227227 {
228- suggestions . push ( CodeActionOrCommand :: Command ( Command {
229- title : format ! ( "Ignore `{}` in the project" , typo) ,
230- command : IGNORE_IN_PROJECT . to_string ( ) ,
231- arguments : Some (
232- [ serde_json :: to_value ( IgnoreInProjectCommandArguments {
233- typo : typo . to_string ( ) ,
234- config_file_path : instance
235- . config_file
236- . to_string_lossy ( )
237- . to_string ( ) ,
238- } )
239- . unwrap ( ) ]
240- . into ( ) ,
241- ) ,
242- } ) ) ;
228+ match serde_json :: to_value ( IgnoreInProjectCommandArguments {
229+ typo : typo. to_string ( ) ,
230+ config_file_path : instance . config_file . clone ( ) ,
231+ } ) {
232+ Ok ( args ) => {
233+ suggestions . push ( CodeActionOrCommand :: Command ( Command {
234+ title : format ! ( "Ignore `{}` in the project" , typo ) ,
235+ command : IGNORE_IN_PROJECT . to_string ( ) ,
236+ arguments : Some ( vec ! [ args ] ) ,
237+ } ) ) ;
238+ }
239+ Err ( e ) => {
240+ tracing :: error! ( "Failed to serialize arguments: {}" , e ) ;
241+ }
242+ }
243243
244244 if let Some ( explicit_config) = & instance. custom_config {
245- suggestions. push ( CodeActionOrCommand :: Command ( Command {
246- title : format ! ( "Ignore `{}` in the configuration file" , typo) ,
247- command : IGNORE_IN_PROJECT . to_string ( ) ,
248- arguments : Some (
249- [ serde_json:: to_value ( IgnoreInProjectCommandArguments {
250- typo : typo. to_string ( ) ,
251- config_file_path : explicit_config. to_string_lossy ( ) . to_string ( ) ,
252- } )
253- . unwrap ( ) ]
254- . into ( ) ,
255- ) ,
256- } ) ) ;
245+ match serde_json:: to_value ( IgnoreInProjectCommandArguments {
246+ typo : typo. to_string ( ) ,
247+ config_file_path : explicit_config. clone ( ) ,
248+ } ) {
249+ Ok ( args) => {
250+ suggestions. push ( CodeActionOrCommand :: Command ( Command {
251+ title : format ! ( "Ignore `{}` in the configuration file" , typo) ,
252+ command : IGNORE_IN_PROJECT . to_string ( ) ,
253+ arguments : Some ( vec ! [ args] ) ,
254+ } ) ) ;
255+ }
256+ Err ( e) => {
257+ tracing:: error!( "Failed to serialize arguments: {}" , e) ;
258+ }
259+ }
257260 }
258261 } else {
259262 tracing:: warn!(
@@ -305,8 +308,7 @@ impl LanguageServer for Backend<'static, 'static> {
305308 ..
306309 } ) = serde_json:: from_value :: < IgnoreInProjectCommandArguments > ( argument)
307310 {
308- crate :: config:: add_ignore ( PathBuf :: from ( config_file_path) . as_path ( ) , & typo)
309- . unwrap ( ) ;
311+ crate :: config:: add_ignore ( & config_file_path, & typo) . unwrap ( ) ;
310312 // reload the instance so new ignore takes effect
311313 self . state . lock ( ) . unwrap ( ) . update_router ( ) . unwrap ( ) ;
312314 } ;
0 commit comments