editor repaints any errors when rendered (#3260)
* editor repaints any errors when rendered Signed-off-by: Jess Frazelle <github@jessfraz.com> * Update src/lang/KclSingleton.ts * fix test Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix typo --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
This commit is contained in:
@ -8226,8 +8226,8 @@ test('Typing KCL errors induces a badge on the error logs pane button', async ({
|
||||
await u.closeDebugPanel()
|
||||
|
||||
// Ensure no badge is present
|
||||
const errorLogsButton = page.getByRole('button', { name: 'KCL Code pane' })
|
||||
await expect(errorLogsButton).not.toContainText('notification')
|
||||
const codePaneButton = page.getByRole('button', { name: 'KCL Code pane' })
|
||||
await expect(codePaneButton).not.toContainText('notification')
|
||||
|
||||
// Delete a character to break the KCL
|
||||
await u.openKclCodePanel()
|
||||
@ -8235,5 +8235,69 @@ test('Typing KCL errors induces a badge on the error logs pane button', async ({
|
||||
await page.keyboard.press('Backspace')
|
||||
|
||||
// Ensure that a badge appears on the button
|
||||
await expect(errorLogsButton).toContainText('notification')
|
||||
await expect(codePaneButton).toContainText('notification')
|
||||
})
|
||||
|
||||
test('Opening and closing the code pane will consistently show error diagnostics', async ({
|
||||
page,
|
||||
}) => {
|
||||
const u = await getUtils(page)
|
||||
|
||||
// Load the app with the working starter code
|
||||
await page.addInitScript((code) => {
|
||||
localStorage.setItem('persistCode', code)
|
||||
}, bracket)
|
||||
|
||||
await page.setViewportSize({ width: 1200, height: 900 })
|
||||
await u.waitForAuthSkipAppStart()
|
||||
|
||||
// wait for execution done
|
||||
await u.openDebugPanel()
|
||||
await u.expectCmdLog('[data-message-type="execution-done"]')
|
||||
await u.closeDebugPanel()
|
||||
|
||||
// Ensure we have no errors in the gutter.
|
||||
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
|
||||
|
||||
// Ensure no badge is present
|
||||
const codePaneButton = page.getByRole('button', { name: 'KCL Code pane' })
|
||||
await expect(codePaneButton).not.toContainText('notification')
|
||||
|
||||
// Delete a character to break the KCL
|
||||
await u.openKclCodePanel()
|
||||
await page.getByText('extrude(').click()
|
||||
await page.keyboard.press('Backspace')
|
||||
|
||||
// Ensure that a badge appears on the button
|
||||
await expect(codePaneButton).toContainText('notification')
|
||||
|
||||
// Ensure we have an error diagnostic.
|
||||
await expect(page.locator('.cm-lint-marker-error')).toBeVisible()
|
||||
|
||||
// error text on hover
|
||||
await page.hover('.cm-lint-marker-error')
|
||||
await expect(page.getByText('Unexpected token').first()).toBeVisible()
|
||||
|
||||
// Close the code pane
|
||||
u.closeKclCodePanel()
|
||||
|
||||
await page.waitForTimeout(500)
|
||||
|
||||
// Ensure that a badge appears on the button
|
||||
await expect(codePaneButton).toContainText('notification')
|
||||
// Ensure we have no errors in the gutter.
|
||||
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
|
||||
|
||||
// Open the code pane
|
||||
u.openKclCodePanel()
|
||||
|
||||
// Ensure that a badge appears on the button
|
||||
await expect(codePaneButton).toContainText('notification')
|
||||
|
||||
// Ensure we have an error diagnostic.
|
||||
await expect(page.locator('.cm-lint-marker-error')).toBeVisible()
|
||||
|
||||
// error text on hover
|
||||
await page.hover('.cm-lint-marker-error')
|
||||
await expect(page.getByText('Unexpected token').first()).toBeVisible()
|
||||
})
|
||||
|
6
src-tauri/Cargo.lock
generated
6
src-tauri/Cargo.lock
generated
@ -2775,7 +2775,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.48.5",
|
||||
"windows-targets 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4638,9 +4638,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.121"
|
||||
version = "1.0.122"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609"
|
||||
checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da"
|
||||
dependencies = [
|
||||
"indexmap 2.2.6",
|
||||
"itoa 1.0.11",
|
||||
|
@ -193,6 +193,10 @@ export const KclEditorPane = () => {
|
||||
if (_editorView === null) return
|
||||
|
||||
editorManager.setEditorView(_editorView)
|
||||
|
||||
// On first load of this component, ensure we show the current errors
|
||||
// in the editor.
|
||||
kclManager.setDiagnosticsForCurrentErrors()
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -91,12 +91,16 @@ export class KclManager {
|
||||
set kclErrors(kclErrors) {
|
||||
if (kclErrors === this._kclErrors && this.lints.length === 0) return
|
||||
this._kclErrors = kclErrors
|
||||
let diagnostics = kclErrorsToDiagnostics(kclErrors)
|
||||
this.setDiagnosticsForCurrentErrors()
|
||||
this._kclErrorsCallBack(kclErrors)
|
||||
}
|
||||
|
||||
setDiagnosticsForCurrentErrors() {
|
||||
let diagnostics = kclErrorsToDiagnostics(this.kclErrors)
|
||||
if (this.lints.length > 0) {
|
||||
diagnostics = diagnostics.concat(this.lints)
|
||||
}
|
||||
editorManager.setDiagnostics(diagnostics)
|
||||
this._kclErrorsCallBack(kclErrors)
|
||||
}
|
||||
|
||||
addKclErrors(kclErrors: KCLError[]) {
|
||||
|
Reference in New Issue
Block a user