File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,32 @@ export class MojoLSPManager extends DisposableContext {
322322 return next ( method , param ) ;
323323 }
324324 } ,
325+ async handleDiagnostics ( uri , diagnostics , next ) {
326+ if ( config . get < boolean > (
327+ 'lsp.suppress.diagnostics.in.docstring' ,
328+ /*workspaceFolder=*/ undefined ,
329+ false ,
330+ ) ) {
331+ const document = await vscode . workspace . openTextDocument ( uri ) ;
332+ const foldingRanges = await vscode . commands . executeCommand < vscode . FoldingRange [ ] > (
333+ 'vscode.executeFoldingRangeProvider' ,
334+ uri ,
335+ ) ;
336+ const docstringRanges = foldingRanges . filter ( r => {
337+ return document . lineAt ( r . start ) . text . trimStart ( ) . startsWith ( '"""' )
338+ } ) ;
339+ diagnostics = diagnostics . filter ( d => {
340+ for ( let index = 0 ; index < docstringRanges . length ; index ++ ) {
341+ const range = docstringRanges [ index ] ;
342+ if ( d . range . start . line > range . start && d . range . end . line < range . end ) {
343+ return false ;
344+ }
345+ }
346+ return true ;
347+ } ) ;
348+ }
349+ next ( uri , diagnostics ) ;
350+ } ,
325351 } ;
326352
327353 // Create the language client and start the client.
Original file line number Diff line number Diff line change 159159 "type" : " string"
160160 }
161161 },
162+ "mojo.lsp.suppress.diagnostics.in.docstring" : {
163+ "scope" : " resource" ,
164+ "type" : " boolean" ,
165+ "default" : false ,
166+ "description" : " Suppress warnings and errors in docstring."
167+ },
162168 "mojo.formatting.args" : {
163169 "scope" : " resource" ,
164170 "type" : " array" ,
You can’t perform that action at this time.
0 commit comments