diff --git a/e2e/playwright/flow-tests.spec.ts b/e2e/playwright/flow-tests.spec.ts index d2abafb40..0a8e90670 100644 --- a/e2e/playwright/flow-tests.spec.ts +++ b/e2e/playwright/flow-tests.spec.ts @@ -1511,6 +1511,8 @@ test.describe('Can create sketches on all planes and their back sides', () => { }) test.describe('Copilot ghost text', () => { + test.skip(true, 'Needs to get covered again') + test('completes code in empty file', async ({ page }) => { const u = await getUtils(page) // const PUR = 400 / 37.5 //pixeltoUnitRatio diff --git a/packages/codemirror-lsp-client/src/plugin/lsp.ts b/packages/codemirror-lsp-client/src/plugin/lsp.ts index f13f80842..b0350bb43 100644 --- a/packages/codemirror-lsp-client/src/plugin/lsp.ts +++ b/packages/codemirror-lsp-client/src/plugin/lsp.ts @@ -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({ diff --git a/src/lang/KclSingleton.ts b/src/lang/KclSingleton.ts index bca2e2098..5a5b69773 100644 --- a/src/lang/KclSingleton.ts +++ b/src/lang/KclSingleton.ts @@ -190,11 +190,6 @@ export class KclManager { const currentExecutionId = executionId || Date.now() this._cancelTokens.set(currentExecutionId, false) - // here we're going to clear diagnostics since we're the first - // one in. We're the only location where diagnostics are cleared; - // everything from here on out should be *appending*. - editorManager.clearDiagnostics() - this.isExecuting = true await this.ensureWasmInit() const { logs, errors, programMemory } = await executeAst({ @@ -272,11 +267,6 @@ export class KclManager { await this?.engineCommandManager?.waitForReady this._ast = { ...newAst } - // here we're going to clear diagnostics since we're the first - // one in. We're the only location where diagnostics are cleared; - // everything from here on out should be *appending*. - editorManager.clearDiagnostics() - const { logs, errors, programMemory } = await executeAst({ ast: newAst, engineCommandManager: this.engineCommandManager, diff --git a/src/wasm-lib/kcl/src/lsp/copilot/mod.rs b/src/wasm-lib/kcl/src/lsp/copilot/mod.rs index 24c67c5e9..da8054c40 100644 --- a/src/wasm-lib/kcl/src/lsp/copilot/mod.rs +++ b/src/wasm-lib/kcl/src/lsp/copilot/mod.rs @@ -223,7 +223,8 @@ impl Backend { #[cfg(not(test))] let mut completion_list = vec![]; - if self.dev_mode { + // if self.dev_mode + if false { completion_list.push( r#"fn cube = (pos, scale) => { const sg = startSketchOn('XY')