Compare commits

...

4 Commits

Author SHA1 Message Date
4e7c00f017 Merge branch 'main' into kurt-6846 2025-05-12 13:17:04 +10:00
3f2a3ed8a9 add test 2025-05-12 12:48:54 +10:00
731d077d73 Update src/editor/plugins/lsp/kcl/index.ts
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-05-12 11:55:21 +10:00
5471c9cce9 stop path to node from getting stale 2025-05-12 11:52:50 +10:00
3 changed files with 48 additions and 3 deletions

View File

@ -841,6 +841,49 @@ washer = extrude(washerSketch, length = thicknessMax)`
await editor.expectEditor.toContain('@settings(defaultLengthUnit = yd)')
})
})
test('Cursor position updates correctly after typing', async ({
page,
homePage,
toolbar,
context,
}) => {
await page.setBodyDimensions({ width: 1200, height: 500 })
await context.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`at = [33.49, 26.29]
sketch001 = startSketchOn(XZ)
|> startProfile(at)
|> line(end = [67.38, 84.9])
|> line(end = [115.66, -75.17])
`
)
})
await homePage.goToModelingScene()
await toolbar.openFeatureTreePane()
await expect(page.getByText('Errors found in KCL code.')).toBeVisible({
timeout: 15_000,
})
await page
.getByText('startProfile', {
exact: true,
})
.click()
await page.keyboard.press('End')
await page.keyboard.press('ArrowLeft')
await page.waitForTimeout(200)
await page.keyboard.type(' = at')
await page.waitForTimeout(200)
await toolbar.waitForFeatureTreeToBeBuilt()
// wait for error (this timeout want finish because it hit the ./lib/console-error-whitelist.ts code if the regression still exists)
await page.waitForTimeout(2000)
})
})
async function clickExportButton(page: Page) {

View File

@ -64,12 +64,14 @@ export class KclPlugin implements PluginValue {
editorManager.setEditorView(viewUpdate.view)
let isUserSelect = false
let didUserType = false
let isRelevant = viewUpdate.docChanged
for (const tr of viewUpdate.transactions) {
if (tr.isUserEvent('select')) {
isUserSelect = true
} else if (tr.isUserEvent('input')) {
isRelevant = true
didUserType = true
} else if (tr.isUserEvent('delete')) {
isRelevant = true
} else if (tr.isUserEvent('undo')) {
@ -108,7 +110,7 @@ export class KclPlugin implements PluginValue {
// If we have a user select event, we want to update what parts are
// highlighted.
if (isUserSelect) {
if (isUserSelect || didUserType) {
this._deffererUserSelect(true)
return
}

View File

@ -131,8 +131,8 @@ export function getNodeFromPath<T>(
if (
typeof stopAt !== 'undefined' &&
(isArray(stopAt)
? stopAt.includes(currentNode.type)
: currentNode.type === stopAt)
? stopAt.includes(currentNode?.type)
: currentNode?.type === stopAt)
) {
// it will match the deepest node of the type
// instead of returning at the first match