Clear the diagnostics before processing (#3118)
clear diagnostics when we update the text Signed-off-by: Paul R. Tagliamonte <paul@zoo.dev>
This commit is contained in:
@ -17,6 +17,7 @@ import type {
|
||||
PluginSpec,
|
||||
ViewPlugin,
|
||||
} from '@codemirror/view'
|
||||
import { setDiagnosticsEffect } from '@codemirror/lint'
|
||||
import { EditorView, Tooltip } from '@codemirror/view'
|
||||
|
||||
import type { PublishDiagnosticsParams } from 'vscode-languageserver-protocol'
|
||||
@ -214,6 +215,21 @@ export class LanguageServerPlugin implements PluginValue {
|
||||
}
|
||||
|
||||
if (!this.client.ready) return
|
||||
|
||||
// TODO(paultag): This is the *wrong* place for this to live.
|
||||
//
|
||||
// We need to clear diagnostics before updating the code, because
|
||||
// if the code shrinks, the errors/diagnostics can go out of range
|
||||
// of the source code, which cause an exception, breaking all the
|
||||
// things.
|
||||
//
|
||||
// We need some sort of clear diagnostics boolean on the editor
|
||||
// and we can drop this.
|
||||
this.view.dispatch({
|
||||
effects: [setDiagnosticsEffect.of([])],
|
||||
annotations: [],
|
||||
})
|
||||
|
||||
try {
|
||||
// Update the state (not the editor) with the new code.
|
||||
this.client.textDocumentDidChange({
|
||||
|
Reference in New Issue
Block a user