initialize codemirror lint styles once (#3185)

* fix diagnostic styles

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Revert "fixes"

This reverts commit e7b2411ebc.

* Revert "fix diagnostic styles"

This reverts commit 625099d9c8.

* actual fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-07-29 21:42:05 -07:00
committed by GitHub
parent 60c152bf14
commit 6e296af507

View File

@ -6,7 +6,11 @@ import { Selections, processCodeMirrorRanges, Selection } from 'lib/selections'
import { undo, redo } from '@codemirror/commands' import { undo, redo } from '@codemirror/commands'
import { CommandBarMachineEvent } from 'machines/commandBarMachine' import { CommandBarMachineEvent } from 'machines/commandBarMachine'
import { addLineHighlight, addLineHighlightEvent } from './highlightextension' import { addLineHighlight, addLineHighlightEvent } from './highlightextension'
import { Diagnostic, setDiagnosticsEffect } from '@codemirror/lint' import {
Diagnostic,
setDiagnostics,
setDiagnosticsEffect,
} from '@codemirror/lint'
const updateOutsideEditorAnnotation = Annotation.define<boolean>() const updateOutsideEditorAnnotation = Annotation.define<boolean>()
export const updateOutsideEditorEvent = updateOutsideEditorAnnotation.of(true) export const updateOutsideEditorEvent = updateOutsideEditorAnnotation.of(true)
@ -53,6 +57,12 @@ export default class EditorManager {
} }
setEditorView(editorView: EditorView) { setEditorView(editorView: EditorView) {
if (!this._editorView) {
// Initialize lint.
// This will initialize all the styles etc.
// We only want to do this once.
editorView.dispatch(setDiagnostics(editorView.state, []))
}
this._editorView = editorView this._editorView = editorView
} }