* Fix error of not showing errors when reopening KCL code pane * add test for errors not shown after reopening code pane * rename test * typo in e2e/playwright/editor-tests.spec.ts Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> * lint * fmt * fix test: Opening and closing the code pane will consistently show error diagnostics * PR feedback: use catch(reportRejection) for safeParse * no need for lint rule --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
This commit is contained in:
@ -53,6 +53,7 @@ import {
|
||||
kclEditorActor,
|
||||
selectionEventSelector,
|
||||
} from '@src/machines/kclEditorMachine'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
|
||||
export const editorShortcutMeta = {
|
||||
formatCode: {
|
||||
@ -210,12 +211,19 @@ export const KclEditorPane = () => {
|
||||
editorManager.setEditorView(_editorView)
|
||||
kclEditorActor.send({ type: 'setKclEditorMounted', data: true })
|
||||
|
||||
// On first load of this component, ensure we show the current errors
|
||||
// in the editor.
|
||||
// Make sure we don't add them twice.
|
||||
if (diagnosticCount(_editorView.state) === 0) {
|
||||
kclManager.setDiagnosticsForCurrentErrors()
|
||||
}
|
||||
// Update diagnostics as they are cleared when the editor is unmounted.
|
||||
// Without this, errors would not be shown when closing and reopening the editor.
|
||||
kclManager
|
||||
.safeParse(codeManager.code)
|
||||
.then(() => {
|
||||
// On first load of this component, ensure we show the current errors
|
||||
// in the editor.
|
||||
// Make sure we don't add them twice.
|
||||
if (diagnosticCount(_editorView.state) === 0) {
|
||||
kclManager.setDiagnosticsForCurrentErrors()
|
||||
}
|
||||
})
|
||||
.catch(reportRejection)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user