File tree 2 files changed +26
-17
lines changed
2 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -328,8 +328,33 @@ impl GlobalState {
328
328
}
329
329
330
330
let uri = file_id_to_url ( & self . vfs . read ( ) . 0 , file_id) ;
331
- let diagnostics =
331
+ let mut diagnostics =
332
332
self . diagnostics . diagnostics_for ( file_id) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
333
+
334
+ // VSCode assumes diagnostic messages to be non-empty strings, so we need to patch
335
+ // empty diagnostics. Neither the docs of VSCode nor the LSP spec say whether
336
+ // diagnostic messages are actually allowed to be empty or not and patching this
337
+ // in the VSCode client does not work as the assertion happens in the protocol
338
+ // conversion. So this hack is here to stay, and will be considered a hack
339
+ // until the LSP decides to state that empty messages are allowed.
340
+
341
+ // See https://github.com/rust-lang/rust-analyzer/issues/11404
342
+ // See https://github.com/rust-lang/rust-analyzer/issues/13130
343
+ let patch_empty = |message : & mut String | {
344
+ if message. is_empty ( ) {
345
+ * message = " " . to_string ( ) ;
346
+ }
347
+ } ;
348
+
349
+ for d in & mut diagnostics {
350
+ patch_empty ( & mut d. message ) ;
351
+ if let Some ( dri) = & mut d. related_information {
352
+ for dri in dri {
353
+ patch_empty ( & mut dri. message ) ;
354
+ }
355
+ }
356
+ }
357
+
333
358
let version = from_proto:: vfs_path ( & uri)
334
359
. map ( |path| self . mem_docs . get ( & path) . map ( |it| it. version ) )
335
360
. unwrap_or_default ( ) ;
Original file line number Diff line number Diff line change @@ -99,22 +99,6 @@ export async function createClient(
99
99
traceOutputChannel : traceOutputChannel ( ) ,
100
100
outputChannel : outputChannel ( ) ,
101
101
middleware : {
102
- async handleDiagnostics ( uri , diagnostics , next ) {
103
- // Workaround for https://github.com/microsoft/vscode/issues/155531
104
- for ( const diagnostic of diagnostics ) {
105
- if ( ! diagnostic . message ) {
106
- diagnostic . message = " " ;
107
- }
108
- if ( diagnostic . relatedInformation ) {
109
- for ( const relatedInformation of diagnostic . relatedInformation ) {
110
- if ( ! relatedInformation . message ) {
111
- relatedInformation . message = " " ;
112
- }
113
- }
114
- }
115
- }
116
- next ( uri , diagnostics ) ;
117
- } ,
118
102
async provideHover (
119
103
document : vscode . TextDocument ,
120
104
position : vscode . Position ,
You can’t perform that action at this time.
0 commit comments