File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,10 @@ impl LanguageServer for Backend {
3131 // TODO: Workspace folders / settings
3232 let mut cwd = "" . to_string ( ) ;
3333 if params. root_uri . is_some ( ) {
34- cwd = params
35- . root_uri
36- . unwrap ( )
37- . to_file_path ( )
38- . unwrap ( )
39- . to_str ( )
40- . unwrap ( )
41- . to_string ( ) ;
34+ let path = params. root_uri . unwrap ( ) . to_file_path ( ) ;
35+ if path. is_ok ( ) {
36+ cwd = path. unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
37+ }
4238 }
4339
4440 self . param_map
@@ -315,9 +311,15 @@ impl LanguageServer for Backend {
315311 return Ok ( None ) ;
316312 }
317313
318- let d = params. context . diagnostics [ 0 ] . data . as_ref ( ) . unwrap ( ) ;
319- let s = serde_json:: to_string ( d) . unwrap ( ) ;
314+ let diagnostics = params. context . diagnostics [ 0 ] . data . as_ref ( ) ;
315+ if diagnostics. is_none ( ) {
316+ // TODO: What case is this?
317+ //
318+ // See https://github.com/ChrisChinchilla/vale-vscode/issues/48
319+ return Ok ( None ) ;
320+ }
320321
322+ let s = serde_json:: to_string ( diagnostics. unwrap ( ) ) . unwrap ( ) ;
321323 match self . cli . fix ( & s) {
322324 Ok ( fixed) => {
323325 let alert: vale:: ValeAlert = serde_json:: from_str ( & s) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments