diff --git a/e2e/playwright/basic-sketch.spec.ts b/e2e/playwright/basic-sketch.spec.ts index 192b8a41b..3cb1e78fb 100644 --- a/e2e/playwright/basic-sketch.spec.ts +++ b/e2e/playwright/basic-sketch.spec.ts @@ -85,7 +85,7 @@ async function doBasicSketch( await page.mouse.click(startXPx, 500 - PUR * 20) if (openPanes.includes('code')) { await expect(u.codeLocator) - .toHaveText(`sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ + .toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ commonPoints.startAt }, sketch001) |> xLine(length = ${commonPoints.num1}) @@ -119,10 +119,7 @@ async function doBasicSketch( await page.waitForTimeout(100) if (openPanes.includes('code')) { - await expect( - await u.getGreatestPixDiff(line1, TEST_COLORS.BLUE) - ).toBeLessThan(3) - await expect(await u.getGreatestPixDiff(line1, [0, 0, 255])).toBeLessThan(3) + expect(await u.getGreatestPixDiff(line1, TEST_COLORS.BLUE)).toBeLessThan(3) } // hold down shift @@ -145,7 +142,7 @@ async function doBasicSketch( // Open the code pane. await u.openKclCodePanel() await expect(u.codeLocator) - .toHaveText(`sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ + .toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ commonPoints.startAt }, sketch001) |> xLine(length = ${commonPoints.num1}, tag = $seg01) diff --git a/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts b/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts index bb87b7a31..b8e1b9ff0 100644 --- a/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts +++ b/e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts @@ -46,7 +46,7 @@ test.describe( }, } - const code = `sketch001 = startSketchOn(${plane})profile001 = startProfileAt([0.91, -1.22], sketch001)` + const code = `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(${plane})profile001 = startProfileAt([0.91, -1.22], sketch001)` await u.openDebugPanel() diff --git a/e2e/playwright/code-pane-and-errors.spec.ts b/e2e/playwright/code-pane-and-errors.spec.ts index daa21d20d..1908ab38d 100644 --- a/e2e/playwright/code-pane-and-errors.spec.ts +++ b/e2e/playwright/code-pane-and-errors.spec.ts @@ -251,11 +251,11 @@ test( ]) await Promise.all([ fsp.copyFile( - executorInputPath('router-template-slate.kcl'), + executorInputPath('cylinder-inches.kcl'), join(routerTemplateDir, 'main.kcl') ), fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('e2e-can-sketch-on-chamfer.kcl'), join(bracketDir, 'main.kcl') ), ]) diff --git a/e2e/playwright/desktop-export.spec.ts b/e2e/playwright/desktop-export.spec.ts index 91e340907..c4d32ccd1 100644 --- a/e2e/playwright/desktop-export.spec.ts +++ b/e2e/playwright/desktop-export.spec.ts @@ -20,11 +20,11 @@ test( await Promise.all([fsp.mkdir(bracketDir, { recursive: true })]) await Promise.all([ fsp.copyFile( - executorInputPath('router-template-slate.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'other.kcl') ), fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('e2e-can-sketch-on-chamfer.kcl'), path.join(bracketDir, 'main.kcl') ), ]) @@ -107,7 +107,7 @@ test( }, { timeout: 15_000 } ) - .toBeGreaterThan(300_000) + .toBeGreaterThan(30_000) }) }) @@ -187,7 +187,7 @@ test( }, { timeout: 15_000 } ) - .toBeGreaterThan(70_000) + .toBeGreaterThan(50_000) }) }) } diff --git a/e2e/playwright/editor-tests.spec.ts b/e2e/playwright/editor-tests.spec.ts index 6b8f0c50a..e5c436ef4 100644 --- a/e2e/playwright/editor-tests.spec.ts +++ b/e2e/playwright/editor-tests.spec.ts @@ -32,26 +32,30 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => { await page.keyboard.press('/') await page.keyboard.up('ControlOrMeta') - await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XY) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> line(end = [0, 20]) |> line(end = [-20, 0]) - // |> close()`) + // |> close()`.replaceAll('\n', '') + ) // uncomment the code await page.keyboard.down('ControlOrMeta') await page.keyboard.press('/') await page.keyboard.up('ControlOrMeta') - await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XY) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> line(end = [0, 20]) |> line(end = [-20, 0]) - |> close()`) + |> close()`.replaceAll('\n', '') + ) }) test('ensure we use the cache, and do not re-execute', async ({ @@ -178,13 +182,15 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => { await page.locator('#code-pane button:first-child').click() await page.locator('button:has-text("Format code")').click() - await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XY) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> line(end = [0, 20]) |> line(end = [-20, 0]) - |> close()`) + |> close()`.replaceAll('\n', '') + ) }) test('if you click the format button it formats your code and executes so lints are still there', async ({ @@ -227,13 +233,15 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => { await u.expectCmdLog('[data-message-type="execution-done"]') await u.closeDebugPanel() - await expect(page.locator('.cm-content')) - .toHaveText(`sketch_001 = startSketchOn(XY) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch_001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> line(end = [0, 20]) |> line(end = [-20, 0]) - |> close()`) + |> close()`.replaceAll('\n', '') + ) // error in guter await expect(page.locator('.cm-lint-marker-info').first()).toBeVisible() @@ -815,10 +823,12 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => { // there shouldn't be any auto complete options for 'lin' in the comment await expect(page.locator('.cm-completionLabel')).not.toBeVisible() - await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XZ) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([3.14, 12], %) - |> xLine(%, length = 5) // lin`) + |> xLine(%, length = 5) // lin`.replaceAll('\n', '') + ) // expect there to be no KCL errors await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0) @@ -888,10 +898,12 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => { // there shouldn't be any auto complete options for 'lin' in the comment await expect(page.locator('.cm-completionLabel')).not.toBeVisible() - await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XZ) + await expect(page.locator('.cm-content')).toHaveText( + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([3.14, 12], %) - |> xLine(%, length = 5) // lin`) + |> xLine(%, length = 5) // lin`.replaceAll('\n', '') + ) }) }) test('Can undo a click and point extrude with ctrl+z', async ({ diff --git a/e2e/playwright/fixtures/sceneFixture.ts b/e2e/playwright/fixtures/sceneFixture.ts index d7189a672..b47538345 100644 --- a/e2e/playwright/fixtures/sceneFixture.ts +++ b/e2e/playwright/fixtures/sceneFixture.ts @@ -310,7 +310,9 @@ export async function expectPixelColor( .toBeTruthy() .catch((cause) => { throw new Error( - `ExpectPixelColor: expecting ${colour} got ${finalValue}`, + `ExpectPixelColor: point ${JSON.stringify( + coords + )} was expecting ${colour} but got ${finalValue}`, { cause } ) }) diff --git a/e2e/playwright/machines.spec.ts b/e2e/playwright/machines.spec.ts index 097e522de..113f59ffc 100644 --- a/e2e/playwright/machines.spec.ts +++ b/e2e/playwright/machines.spec.ts @@ -11,7 +11,7 @@ test( const bracketDir = join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), join(bracketDir, 'main.kcl') ) }) @@ -51,7 +51,7 @@ test( const bracketDir = join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), join(bracketDir, 'main.kcl') ) }) diff --git a/e2e/playwright/point-click.spec.ts b/e2e/playwright/point-click.spec.ts index edfb181c5..4be3ac008 100644 --- a/e2e/playwright/point-click.spec.ts +++ b/e2e/playwright/point-click.spec.ts @@ -137,7 +137,7 @@ test.describe('Point-and-click tests', () => { await scene.moveCameraTo(cameraPos, cameraTarget) - await test.step('check chamfer selection changes cursor positon', async () => { + await test.step('check chamfer selection changes cursor position', async () => { await expect(async () => { // sometimes initial click doesn't register await clickChamfer() @@ -173,7 +173,7 @@ test.describe('Point-and-click tests', () => { }) await test.step('Check there is no errors after code created in previous steps executes', async () => { await editor.expectState({ - activeLines: ['sketch001 = startSketchOn(XZ)'], + activeLines: ['@settings(defaultLengthUnit = in)'], highlightedCode: '', diagnostics: [], }) @@ -299,7 +299,8 @@ test.describe('Point-and-click tests', () => { await test.step('verify at the end of the test that final code is what is expected', async () => { await editor.expectEditor.toContain( - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag] |> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine([ @@ -369,7 +370,7 @@ profile001 = startProfileAt([205.96, 254.59], sketch002) }) }) - test('Works on chamfers that are non in a pipeExpression can break up multi edges in a chamfer array', async ({ + test('Works on chamfers that are not in a pipeExpression can break up multi edges in a chamfer array', async ({ context, page, homePage, @@ -418,7 +419,8 @@ profile001 = startProfileAt([205.96, 254.59], sketch002) |>close()`, }) await editor.expectEditor.toContain( - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([75.8, 317.2], %) |> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine([ @@ -1639,9 +1641,10 @@ loft001 = loft([sketch001, sketch002]) { targetType: 'circle', testPoint: { x: 700, y: 250 }, - initialCode: `sketch001 = startSketchOn('YZ') + initialCode: `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(YZ) profile001 = circle(sketch001, center = [0, 0], radius = 500) -sketch002 = startSketchOn('XZ') +sketch002 = startSketchOn(XZ) |> startProfileAt([0, 0], %) |> xLine(length = -500) |> tangentialArcTo([-2000, 500], %)`, @@ -1649,7 +1652,8 @@ sketch002 = startSketchOn('XZ') { targetType: 'rectangle', testPoint: { x: 710, y: 255 }, - initialCode: `sketch001 = startSketchOn('YZ') + initialCode: `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(YZ) profile001 = startProfileAt([-400, -400], sketch001) |> angledLine([0, 800], %, $rectangleSegmentA001) |> angledLine([ @@ -1662,7 +1666,7 @@ profile001 = startProfileAt([-400, -400], sketch001) ], %) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() -sketch002 = startSketchOn('XZ') +sketch002 = startSketchOn(XZ) |> startProfileAt([0, 0], %) |> xLine(length = -500) |> tangentialArcTo([-2000, 500], %)`, @@ -1806,7 +1810,8 @@ sketch002 = startSketchOn('XZ') toolbar, cmdBar, }) => { - const initialCode = `sketch001 = startSketchOn(YZ) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(YZ) |> circle( center = [0, 0], radius = 500 @@ -2475,7 +2480,8 @@ extrude001 = extrude(profile001, length = 5) cmdBar, }) => { // Code samples - const initialCode = `sketch001 = startSketchOn(XY) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-12, -6], %) |> line(end = [0, 12]) |> line(end = [24, 0]) @@ -2767,7 +2773,8 @@ extrude001 = extrude(sketch001, length = -12) toolbar, }) => { // Code samples - const initialCode = `sketch001 = startSketchOn(XY) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-12, -6], %) |> line(end = [0, 12]) |> line(end = [24, 0], tag = $seg02) @@ -2921,7 +2928,8 @@ chamfer04 = chamfer(extrude001, length = 5, tags = [getOppositeEdge(seg02)]) toolbar, cmdBar, }) => { - const initialCode = `sketch001 = startSketchOn(XZ) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> circle(center = [0, 0], radius = 30) extrude001 = extrude(sketch001, length = 30) ` @@ -3056,7 +3064,8 @@ extrude001 = extrude(sketch001, length = 30) toolbar, cmdBar, }) => { - const initialCode = `sketch001 = startSketchOn(XY) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XY) |> startProfileAt([-20, 20], %) |> xLine(length = 40) |> yLine(length = -60) @@ -3174,7 +3183,8 @@ extrude001 = extrude(sketch001, length = 40) }) const shellSketchOnFacesCases = [ - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> circle(center = [0, 0], radius = 100) |> extrude(length = 100) @@ -3182,7 +3192,8 @@ sketch002 = startSketchOn(sketch001, 'END') |> circle(center = [0, 0], radius = 50) |> extrude(length = 50) `, - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> circle(center = [0, 0], radius = 100) extrude001 = extrude(sketch001, length = 100) @@ -3578,7 +3589,8 @@ radius = 8.69 toolbar, cmdBar, }) => { - const initialCode = `sketch001 = startSketchOn(XZ) + const initialCode = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = circle( sketch001, center = [0, 0], diff --git a/e2e/playwright/projects.spec.ts b/e2e/playwright/projects.spec.ts index c8d57b112..425fd9d2b 100644 --- a/e2e/playwright/projects.spec.ts +++ b/e2e/playwright/projects.spec.ts @@ -87,7 +87,7 @@ test( const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) }) @@ -124,7 +124,7 @@ test( const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) const errorDir = path.join(dir, 'broken-code') @@ -162,7 +162,7 @@ test( // gray at this pixel means the stream has loaded in the most // user way we can verify it (pixel color) await expect - .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { + .poll(() => u.getGreatestPixDiff(pointOnModel, [110, 110, 110]), { timeout: 10_000, }) .toBeLessThan(20) @@ -213,7 +213,7 @@ test( const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) const emptyDir = path.join(dir, 'empty') @@ -248,7 +248,7 @@ test( // gray at this pixel means the stream has loaded in the most // user way we can verify it (pixel color) await expect - .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { + .poll(() => u.getGreatestPixDiff(pointOnModel, [125, 125, 125]), { timeout: 10_000, }) .toBeLessThan(15) @@ -290,7 +290,7 @@ test( const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) @@ -319,7 +319,7 @@ test( // gray at this pixel means the stream has loaded in the most // user way we can verify it (pixel color) await expect - .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { + .poll(() => u.getGreatestPixDiff(pointOnModel, [125, 125, 125]), { timeout: 10_000, }) .toBeLessThan(15) @@ -359,7 +359,7 @@ test( const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) await fsp.copyFile( @@ -393,7 +393,7 @@ test( // gray at this pixel means the stream has loaded in the most // user way we can verify it (pixel color) await expect - .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { + .poll(() => u.getGreatestPixDiff(pointOnModel, [125, 125, 125]), { timeout: 10_000, }) .toBeLessThan(15) @@ -443,7 +443,6 @@ test( await page.getByText('broken-code').click() // Gotcha: You can not use scene.waitForExecutionDone() since the KCL code is going to fail - await expect(page.getByTestId('loading')).toBeAttached() await expect(page.getByTestId('loading')).not.toBeAttached({ timeout: 20_000, }) @@ -481,7 +480,7 @@ test.describe('Can export from electron app', () => { const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) }) @@ -513,7 +512,7 @@ test.describe('Can export from electron app', () => { // gray at this pixel means the stream has loaded in the most // user way we can verify it (pixel color) await expect - .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { + .poll(() => u.getGreatestPixDiff(pointOnModel, [125, 125, 125]), { timeout: 10_000, }) .toBeLessThan(15) @@ -554,7 +553,7 @@ test.describe('Can export from electron app', () => { }, { timeout: 15_000 } ) - .toBeGreaterThan(300_000) + .toBeGreaterThan(50_000) // clean up exported file await fsp.rm(filepath) @@ -1507,7 +1506,12 @@ test( await u.waitForPageLoad() - await page.locator('.cm-content').fill(`sketch001 = startSketchOn(XZ) + // The file should be prepopulated with the user's unit settings. + await expect(page.locator('.cm-content')).toHaveText( + '@settings(defaultLengthUnit = in)' + ) + + await page.locator('.cm-content').fill(`sketch001 = startSketchOn('XZ') |> startProfileAt([-87.4, 282.92], %) |> line(end = [324.07, 27.199], tag = $seg01) |> line(end = [118.328, -291.754]) diff --git a/e2e/playwright/regression-tests.spec.ts b/e2e/playwright/regression-tests.spec.ts index deb17303f..c261120c6 100644 --- a/e2e/playwright/regression-tests.spec.ts +++ b/e2e/playwright/regression-tests.spec.ts @@ -4,9 +4,9 @@ import path from 'path' import * as fsp from 'fs/promises' import { getUtils, - executorInputPath, TEST_COLORS, TestColor, + executorInputPath, orRunWhenFullSuiteEnabled, } from './test-utils' import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from './storageStates' @@ -331,7 +331,7 @@ extrude001 = extrude(sketch001, length = 50) localStorage.setItem( 'persistCode', `@settings(defaultLengthUnit = mm) -sketch002 = startSketchOn('XY') +sketch002 = startSketchOn(XY) profile002 = startProfileAt([72.24, -52.05], sketch002) |> angledLine([0, 181.26], %, $rectangleSegmentA001) |> angledLine([ @@ -582,7 +582,7 @@ extrude002 = extrude(profile002, length = 150) const bracketDir = path.join(dir, 'bracket') await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), path.join(bracketDir, 'main.kcl') ) }) @@ -619,6 +619,7 @@ extrude002 = extrude(profile002, length = 150) test(`View gizmo stays visible even when zoomed out all the way`, async ({ page, homePage, + scene, }) => { const u = await getUtils(page) @@ -632,7 +633,7 @@ extrude002 = extrude(profile002, length = 150) await test.step(`Load an empty file`, async () => { await page.addInitScript(async () => { - localStorage.setItem('persistCode', '') + localStorage.setItem('persistCode', '@settings(defaultLengthUnit = in)') }) await page.setBodyDimensions({ width: 1200, height: 500 }) await homePage.goToModelingScene() @@ -646,22 +647,31 @@ extrude002 = extrude(profile002, length = 150) timeout: 5000, message: 'Plane color is visible', }) - .toBeLessThanOrEqual(15) + .toBeLessThanOrEqual(20) + await expect(scene.startEditSketchBtn).toBeEnabled() let maxZoomOuts = 10 let middlePixelIsBackgroundColor = (await middlePixelIsColor(bgColor)) < 10 + + console.time('pressing control') + await page.keyboard.down('Control') + while (!middlePixelIsBackgroundColor && maxZoomOuts > 0) { - await page.keyboard.down('Control') - await page.mouse.move(600, 460) - await page.mouse.down({ button: 'right' }) - await page.mouse.move(600, 50, { steps: 20 }) - await page.mouse.up({ button: 'right' }) - await page.keyboard.up('Control') await page.waitForTimeout(100) + await page.mouse.move(650, 460) + console.time('moved to start point') + await page.mouse.down({ button: 'right' }) + console.time('moused down') + await page.mouse.move(650, 50, { steps: 20 }) + console.time('moved to end point') + await page.waitForTimeout(100) + await page.mouse.up({ button: 'right' }) + console.time('moused up') maxZoomOuts-- - middlePixelIsBackgroundColor = (await middlePixelIsColor(bgColor)) < 10 + middlePixelIsBackgroundColor = (await middlePixelIsColor(bgColor)) < 15 } + await page.keyboard.up('Control') expect(middlePixelIsBackgroundColor, { message: 'We should not see the default planes', @@ -678,13 +688,12 @@ extrude002 = extrude(profile002, length = 150) homePage, scene, toolbar, - viewport, }) => { await context.folderSetupFn(async (dir) => { const legoDir = path.join(dir, 'lego') await fsp.mkdir(legoDir, { recursive: true }) await fsp.copyFile( - executorInputPath('lego.kcl'), + executorInputPath('e2e-can-sketch-on-chamfer.kcl'), path.join(legoDir, 'main.kcl') ) }) @@ -697,11 +706,8 @@ extrude002 = extrude(profile002, length = 150) await scene.loadingIndicator.waitFor({ state: 'detached' }) }) await test.step(`The part should start loading quickly, not waiting until execution is complete`, async () => { - await scene.expectPixelColor( - [143, 143, 143], - { x: (viewport?.width ?? 1200) / 2, y: (viewport?.height ?? 500) / 2 }, - 15 - ) + // TODO: use the viewport size to pick the center point, but the `viewport` fixture's values were wrong. + await scene.expectPixelColor([116, 116, 116], { x: 500, y: 250 }, 15) }) }) diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index 40d5eafb8..628f55bca 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -113,7 +113,8 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([2.61, -4.01], %) |> xLine(length = 8.73) |> tangentialArcTo([8.33, -1.31], %)` @@ -159,7 +160,10 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => { await page.mouse.click(700, 200) await expect.poll(u.normalisedEditorCode, { timeout: 1000 }) - .toBe(`sketch002 = startSketchOn(XZ) + .toBe(`@settings(defaultLengthUnit = in) + + +sketch002 = startSketchOn(XZ) sketch001 = startProfileAt([12.34, -12.34], sketch002) |> yLine(length = 12.34) @@ -789,7 +793,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002) 200 ) - let codeStr = 'sketch001 = startSketchOn(XY)' + let codeStr = + '@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XY)' await page.mouse.click(center.x, viewportSize.height * 0.55) await expect(u.codeLocator).toHaveText(codeStr) @@ -868,7 +873,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002) await u.openDebugPanel() - const code = `sketch001 = startSketchOn(-XZ) + const code = `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(-XZ) profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff( scale * 34.8 )}], sketch001) @@ -898,7 +904,7 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff( await page.mouse.move(700, 200, { steps: 10 }) await page.mouse.click(700, 200, { delay: 200 }) await expect(page.locator('.cm-content')).toHaveText( - `sketch001 = startSketchOn(-XZ)` + `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(-XZ)` ) let prevContent = await page.locator('.cm-content').innerText() @@ -1426,7 +1432,8 @@ test.describe(`Sketching with offset planes`, () => { await context.addInitScript(() => { localStorage.setItem( 'persistCode', - `offsetPlane001 = offsetPlane(XY, offset = 10)` + `@settings(defaultLengthUnit = in) +offsetPlane001 = offsetPlane(XY, offset = 10)` ) }) @@ -1440,7 +1447,7 @@ test.describe(`Sketching with offset planes`, () => { await test.step(`Hovering should highlight code`, async () => { await planeHover() await editor.expectState({ - activeLines: [`offsetPlane001=offsetPlane(XY,offset=10)`], + activeLines: [`@settings(defaultLengthUnit = in)`], diagnostics: [], highlightedCode: 'offsetPlane(XY, offset = 10)', }) @@ -1453,7 +1460,7 @@ test.describe(`Sketching with offset planes`, () => { await expect(toolbar.lineBtn).toBeEnabled() await editor.expectEditor.toContain('startSketchOn(offsetPlane001)') await editor.expectState({ - activeLines: [`offsetPlane001=offsetPlane(XY,offset=10)`], + activeLines: [`@settings(defaultLengthUnit = in)`], diagnostics: [], highlightedCode: '', }) @@ -1604,7 +1611,8 @@ profile002 = startProfileAt([117.2, 56.08], sketch001) await context.addInitScript(() => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile002 = startProfileAt([40.68, 87.67], sketch001) |> xLine(length = 239.17) profile003 = startProfileAt([206.63, -56.73], sketch001) @@ -2172,7 +2180,8 @@ profile003 = startProfileAt([206.63, -56.73], sketch001) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([6.24, 4.54], sketch001) |> line(end = [-0.41, 6.99]) |> line(end = [8.61, 0.74]) @@ -2317,7 +2326,8 @@ profile004 = circleThreePoint(sketch001, p1 = [13.44, -6.8], p2 = [13.39, -2.07] await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([6.24, 4.54], sketch001) |> line(end = [-0.41, 6.99]) |> line(end = [8.61, 0.74]) @@ -2422,7 +2432,8 @@ profile003 = circle(sketch001, center = [6.92, -4.2], radius = 3.16) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([-63.43, 193.08], sketch001) |> line(end = [168.52, 149.87]) |> line(end = [190.29, -39.18]) @@ -2486,7 +2497,11 @@ extrude001 = extrude(profile003, length = 5) page, }) => { await page.addInitScript(async () => { - localStorage.setItem('persistCode', `myVar = 5`) + localStorage.setItem( + 'persistCode', + `@settings(defaultLengthUnit = in) + myVar = 5` + ) }) await page.setBodyDimensions({ width: 1000, height: 500 }) @@ -2533,7 +2548,8 @@ extrude001 = extrude(profile003, length = 5) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([85.19, 338.59], sketch001) |> line(end = [213.3, -94.52]) |> line(end = [-230.09, -55.34]) @@ -2575,7 +2591,8 @@ profile002 = startProfileAt([85.81, 52.55], sketch002) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `thePart = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +thePart = startSketchOn(XZ) |> startProfileAt([7.53, 10.51], %) |> line(end = [12.54, 1.83]) |> line(end = [6.65, -6.91]) @@ -2636,7 +2653,8 @@ extrude001 = extrude(thePart, length = 75) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([6.71, -3.66], sketch001) |> line(end = [2.65, 9.02], tag = $seg02) |> line(end = [3.73, -9.36], tag = $seg01) @@ -2809,7 +2827,8 @@ extrude003 = extrude(profile011, length = 2.5) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([34, 42.66], sketch001) |> line(end = [102.65, 151.99]) |> line(end = [76, -138.66]) diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png index bafda85ec..6c1e7328f 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png index a9b804037..c296a47dd 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png index b76e1d372..f9ccdb768 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png index 4639dd176..ae548a4c7 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png index 67be72dda..1982b8e27 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png index 54f4245f4..bf368ba0d 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png index 99c8f10b7..d7eef465c 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png index 50f96a32c..3b65cf723 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png index 810142ea3..d2a9c2f82 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png index ab06182d5..1335cd834 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png index ab57f9878..0b8272eec 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png index b5d4021ed..89360c26b 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png index 64eca362c..448f90c91 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png index 6108c993e..194f2f225 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png index 8d2141c5b..e83edbcd2 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png index 318b7e38a..d519fa0d7 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png index 13796e571..0f3146fd6 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png index 9359b7a8a..be1d17822 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png index 08c79298d..1ddd4a57a 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png index e3bd750ff..c19e3f422 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshots/prompt-to-edit/prompt-to-edit-snapshot-tests-spec-ts--change-colour.snap.json b/e2e/playwright/snapshots/prompt-to-edit/prompt-to-edit-snapshot-tests-spec-ts--change-colour.snap.json index 5058c2c40..00de798d1 100644 --- a/e2e/playwright/snapshots/prompt-to-edit/prompt-to-edit-snapshot-tests-spec-ts--change-colour.snap.json +++ b/e2e/playwright/snapshots/prompt-to-edit/prompt-to-edit-snapshot-tests-spec-ts--change-colour.snap.json @@ -1,5 +1,5 @@ { - "original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn('XY')\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n", + "original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n", "prompt": "make this neon green please, use #39FF14", "source_ranges": [ { @@ -30,4 +30,4 @@ } ], "kcl_version": "0.2.48" -} \ No newline at end of file +} diff --git a/e2e/playwright/testing-constraints.spec.ts b/e2e/playwright/testing-constraints.spec.ts index e820fdc9a..c1bcb2bb7 100644 --- a/e2e/playwright/testing-constraints.spec.ts +++ b/e2e/playwright/testing-constraints.spec.ts @@ -4,7 +4,6 @@ import { getUtils, TEST_COLORS, pollEditorLinesSelectedLength, - executorInputPath, orRunWhenFullSuiteEnabled, } from './test-utils' import { XOR } from 'lib/utils' @@ -81,7 +80,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 79 + `@settings(defaultLengthUnit = in) + yo = 79 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4], tag = $seg01) @@ -145,7 +145,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4], tag = $seg01) @@ -277,7 +278,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -387,7 +389,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -500,7 +503,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -602,7 +606,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -688,7 +693,8 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) +yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -768,7 +774,8 @@ part002 = startSketchOn(XZ) await page.addInitScript(async (customCode) => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -869,7 +876,8 @@ part002 = startSketchOn(XZ) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -950,7 +958,8 @@ part002 = startSketchOn(XZ) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yo = 5 + `@settings(defaultLengthUnit = in) + yo = 5 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> line(end = [74.36, 130.4]) @@ -1117,9 +1126,19 @@ test.describe('Electron constraint tests', () => { await context.folderSetupFn(async (dir) => { const bracketDir = path.join(dir, 'test-sample') await fsp.mkdir(bracketDir, { recursive: true }) - await fsp.copyFile( - executorInputPath('angled_line.kcl'), - path.join(bracketDir, 'main.kcl') + await fsp.writeFile( + path.join(bracketDir, 'main.kcl'), + `@settings(defaultLengthUnit = in) + const part001 = startSketchOn(XY) + |> startProfileAt([4.83, 12.56], %) + |> line(end = [15.1, 2.48]) + |> line(end = [3.15, -9.85], tag = $seg01) + |> line(end = [-15.17, -4.1]) + |> angledLine([segAng(seg01), 12.35], %) + |> line(end = [-13.02, 10.03]) + |> close() + |> extrude(length = 4)`, + 'utf-8' ) }) diff --git a/e2e/playwright/testing-gizmo.spec.ts b/e2e/playwright/testing-gizmo.spec.ts index a08382412..75b222b32 100644 --- a/e2e/playwright/testing-gizmo.spec.ts +++ b/e2e/playwright/testing-gizmo.spec.ts @@ -255,7 +255,7 @@ test.describe(`Testing gizmo, fixture-based`, () => { await context.addInitScript(() => { localStorage.setItem( 'persistCode', - ` + `@settings(defaultLengthUnit = in) const sketch002 = startSketchOn(XZ) |> startProfileAt([-108.83, -57.48], %) |> angledLine([0, 105.13], %, $rectangleSegmentA001) diff --git a/e2e/playwright/testing-samples-loading.spec.ts b/e2e/playwright/testing-samples-loading.spec.ts index c894547d4..182925fe9 100644 --- a/e2e/playwright/testing-samples-loading.spec.ts +++ b/e2e/playwright/testing-samples-loading.spec.ts @@ -46,7 +46,7 @@ test.describe('Testing in-app sample loading', () => { page.getByRole('option', { name, }) - const warningText = page.getByText('Overwrite current file and units?') + const warningText = page.getByText('Overwrite current file with sample?') const confirmButton = page.getByRole('button', { name: 'Submit command' }) await test.step(`Precondition: check the initial code`, async () => { @@ -110,11 +110,9 @@ test.describe('Testing in-app sample loading', () => { const commandMethodOption = page.getByRole('option', { name: 'Overwrite', }) - const newFileWarning = page.getByText( - 'Create a new file, overwrite project units?' - ) + const newFileWarning = page.getByText('Create a new file from sample?') const overwriteWarning = page.getByText( - 'Overwrite current file and units?' + 'Overwrite current file with sample?' ) const confirmButton = page.getByRole('button', { name: 'Submit command' }) const projectMenuButton = page.getByTestId('project-sidebar-toggle') diff --git a/e2e/playwright/testing-segment-overlays.spec.ts b/e2e/playwright/testing-segment-overlays.spec.ts index f888909f9..809ad55bb 100644 --- a/e2e/playwright/testing-segment-overlays.spec.ts +++ b/e2e/playwright/testing-segment-overlays.spec.ts @@ -210,7 +210,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([5 + 0, 20 + 0], %) |> line(end = [0.5, -14 + 0]) |> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) @@ -380,7 +381,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `yRel001 = -14 + `@settings(defaultLengthUnit = in) + yRel001 = -14 xRel001 = 0.5 angle001 = 3 len001 = 32 @@ -459,7 +461,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([0, 0], %) |> line(end = [0.5, -14 + 0]) |> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) @@ -590,7 +593,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([0, 0], %) |> line(end = [0.5, -14 + 0]) |> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) @@ -751,7 +755,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([0, 0], %) |> line(end = [0.5, -14 + 0]) |> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) @@ -831,7 +836,8 @@ test.describe('Testing segment overlays', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) profile001 = startProfileAt([56.37, 120.33], sketch001) |> line(end = [162.86, 106.48]) |> arcTo({ @@ -957,7 +963,8 @@ profile001 = startProfileAt([56.37, 120.33], sketch001) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +part001 = startSketchOn(XZ) |> circle(center = [1 + 0, 0], radius = 8) ` ) @@ -1077,7 +1084,8 @@ profile001 = startProfileAt([56.37, 120.33], sketch001) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +part001 = startSketchOn(XZ) |>startProfileAt([0, 0], %) |> line(end = [0.5, -14 + 0]) |> angledLine({ angle = 3 + 0, length = 32 + 0 }, %) @@ -1351,7 +1359,8 @@ profile001 = startProfileAt([56.37, 120.33], sketch001) async ({ lineToBeDeleted, extraLine }) => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([5, 6], %) |> ${lineToBeDeleted} |> line(end = [-10, -15]) @@ -1516,7 +1525,8 @@ profile001 = startProfileAt([56.37, 120.33], sketch001) async ({ lineToBeDeleted }) => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + part001 = startSketchOn(XZ) |> startProfileAt([5, 6], %) |> ${lineToBeDeleted} |> line(end = [-10, -15]) diff --git a/e2e/playwright/testing-selections.spec.ts b/e2e/playwright/testing-selections.spec.ts index 3db4e7f43..0b1ded979 100644 --- a/e2e/playwright/testing-selections.spec.ts +++ b/e2e/playwright/testing-selections.spec.ts @@ -68,20 +68,20 @@ test.describe('Testing selections', { tag: ['@skipWin'] }, () => { await u.closeDebugPanel() await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await expect(page.locator('.cm-content')).toHaveText( - `sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${commonPoints.startAt}, sketch001)` + `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${commonPoints.startAt}, sketch001)` ) await page.waitForTimeout(100) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10) await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${commonPoints.startAt}, sketch001) + .toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${commonPoints.startAt}, sketch001) |> xLine(length = ${commonPoints.num1})`) await page.waitForTimeout(100) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ + .toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ commonPoints.startAt }, sketch001) |> xLine(length = ${commonPoints.num1}) @@ -89,7 +89,7 @@ test.describe('Testing selections', { tag: ['@skipWin'] }, () => { await page.waitForTimeout(100) await page.mouse.click(startXPx, 500 - PUR * 20) await expect(page.locator('.cm-content')) - .toHaveText(`sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ + .toHaveText(`@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)profile001 = startProfileAt(${ commonPoints.startAt }, sketch001) |> xLine(length = ${commonPoints.num1}) @@ -260,7 +260,8 @@ test.describe('Testing selections', { tag: ['@skipWin'] }, () => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([-79.26, 95.04], %) |> line(end = [112.54, 127.64], tag = $seg02) |> line(end = [170.36, -121.61], tag = $seg01) @@ -528,7 +529,8 @@ profile001 = startProfileAt([7.49, 9.96], sketch001) await page.addInitScript(async (KCL_DEFAULT_LENGTH) => { localStorage.setItem( 'persistCode', - `part001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +part001 = startSketchOn(XZ) |> startProfileAt([20, 0], %) |> line(end = [7.13, 4 + 0]) |> angledLine({ angle = 3 + 0, length = 3.14 + 0 }, %) @@ -747,7 +749,8 @@ profile001 = startProfileAt([7.49, 9.96], sketch001) await page.waitForTimeout(200) await u.removeCurrentCode() - await u.codeLocator.fill(`sketch001 = startSketchOn(XZ) + await u.codeLocator.fill(`@settings(defaultLengthUnit = in) + sketch001 = startSketchOn(XZ) |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag] |> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine([ @@ -965,7 +968,8 @@ profile001 = startProfileAt([7.49, 9.96], sketch001) async ({ cases }) => { localStorage.setItem( 'persistCode', - `yo = 79 + `@settings(defaultLengthUnit = in) + yo = 79 part001 = startSketchOn(XZ) |> startProfileAt([-7.54, -26.74], %) |> ${cases[0].expectedCode} @@ -1020,7 +1024,8 @@ profile001 = startProfileAt([7.49, 9.96], sketch001) await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) + sketch001 = startSketchOn(XZ) |> startProfileAt([-79.26, 95.04], %) |> line(end = [112.54, 127.64]) |> line(end = [170.36, -121.61], tag = $seg01) @@ -1253,7 +1258,7 @@ profile001 = startProfileAt([7.49, 9.96], sketch001) await page.mouse.click(700, 200) await expect(page.locator('.cm-content')).toHaveText( - `sketch001 = startSketchOn(XZ)` + `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XZ)` ) await page.waitForTimeout(600) diff --git a/e2e/playwright/testing-settings.spec.ts b/e2e/playwright/testing-settings.spec.ts index 4c24644e8..c57eccf23 100644 --- a/e2e/playwright/testing-settings.spec.ts +++ b/e2e/playwright/testing-settings.spec.ts @@ -271,7 +271,7 @@ test.describe('Testing settings', () => { const bracketDir = join(dir, projectName) await fsp.mkdir(bracketDir, { recursive: true }) await fsp.copyFile( - executorInputPath('focusrite_scarlett_mounting_braket.kcl'), + executorInputPath('cylinder-inches.kcl'), join(bracketDir, 'main.kcl') ) } @@ -699,19 +699,19 @@ test.describe('Testing settings', () => { name: 'Current units are: ', }) await gizmo.click() - const button = page.getByRole('button', { + const button = page.locator('ul').getByRole('button', { name: copy, exact: true, }) await button.click() const toastMessage = page.getByText( - `Set default unit to "${unitOfMeasure}" for this project` + `Updated per-file units to ${unitOfMeasure}` ) await expect(toastMessage).toBeVisible() } - await changeUnitOfMeasureInGizmo('in', 'Inches') await changeUnitOfMeasureInGizmo('ft', 'Feet') + await changeUnitOfMeasureInGizmo('in', 'Inches') await changeUnitOfMeasureInGizmo('yd', 'Yards') await changeUnitOfMeasureInGizmo('mm', 'Millimeters') await changeUnitOfMeasureInGizmo('cm', 'Centimeters') @@ -951,9 +951,9 @@ test.describe('Testing settings', () => { ) }) - await test.step(`Initial units from settings`, async () => { + await test.step(`Initial units from settings are ignored`, async () => { await homePage.openProject('project-000') - await expect(unitsIndicator).toHaveText('Current units are: in') + await expect(unitsIndicator).toHaveText('Current units are: mm') }) await test.step(`Manually write inline settings`, async () => { diff --git a/e2e/playwright/various.spec.ts b/e2e/playwright/various.spec.ts index 90a4283c5..d49ff9514 100644 --- a/e2e/playwright/various.spec.ts +++ b/e2e/playwright/various.spec.ts @@ -483,7 +483,8 @@ test('Sketch on face', async ({ page, homePage, scene, cmdBar, toolbar }) => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', - `sketch001 = startSketchOn(XZ) + `@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([3.29, 7.86], %) |> line(end = [2.48, 2.44]) |> line(end = [2.66, 1.17]) diff --git a/rust/kcl-derive-docs/src/lib.rs b/rust/kcl-derive-docs/src/lib.rs index 4cfb9a989..0d39fdd1c 100644 --- a/rust/kcl-derive-docs/src/lib.rs +++ b/rust/kcl-derive-docs/src/lib.rs @@ -816,7 +816,7 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr async fn #test_name() -> miette::Result<()> { let code = #code_block; // Note, `crate` must be kcl_lib - let result = match crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm, None).await { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/args_with_lifetime.gen b/rust/kcl-derive-docs/tests/args_with_lifetime.gen index 60c38a161..a79915c3c 100644 --- a/rust/kcl-derive-docs/tests/args_with_lifetime.gen +++ b/rust/kcl-derive-docs/tests/args_with_lifetime.gen @@ -31,13 +31,7 @@ mod test_examples_someFn { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_someFn0() -> miette::Result<()> { let code = "someFn()"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/args_with_refs.gen b/rust/kcl-derive-docs/tests/args_with_refs.gen index 679b8194c..5b6c36566 100644 --- a/rust/kcl-derive-docs/tests/args_with_refs.gen +++ b/rust/kcl-derive-docs/tests/args_with_refs.gen @@ -31,13 +31,7 @@ mod test_examples_someFn { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_someFn0() -> miette::Result<()> { let code = "someFn()"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/array.gen b/rust/kcl-derive-docs/tests/array.gen index 56d7871d4..9af507c30 100644 --- a/rust/kcl-derive-docs/tests/array.gen +++ b/rust/kcl-derive-docs/tests/array.gen @@ -32,13 +32,7 @@ mod test_examples_show { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_show0() -> miette::Result<()> { let code = "This is another code block.\nyes sirrr.\nshow"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/box.gen b/rust/kcl-derive-docs/tests/box.gen index be96f7080..a613af7bc 100644 --- a/rust/kcl-derive-docs/tests/box.gen +++ b/rust/kcl-derive-docs/tests/box.gen @@ -32,13 +32,7 @@ mod test_examples_show { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_show0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nshow"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/doc_comment_with_code.gen b/rust/kcl-derive-docs/tests/doc_comment_with_code.gen index b1ba0cfe9..b4410a3e5 100644 --- a/rust/kcl-derive-docs/tests/doc_comment_with_code.gen +++ b/rust/kcl-derive-docs/tests/doc_comment_with_code.gen @@ -33,13 +33,7 @@ mod test_examples_my_func { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_my_func0() -> miette::Result<()> { let code = "This is another code block.\nyes sirrr.\nmyFunc"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/lineTo.gen b/rust/kcl-derive-docs/tests/lineTo.gen index ff2f2bd4e..17acfb8a0 100644 --- a/rust/kcl-derive-docs/tests/lineTo.gen +++ b/rust/kcl-derive-docs/tests/lineTo.gen @@ -33,13 +33,7 @@ mod test_examples_line_to { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_line_to0() -> miette::Result<()> { let code = "This is another code block.\nyes sirrr.\nlineTo"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/min.gen b/rust/kcl-derive-docs/tests/min.gen index 6009394a2..435322812 100644 --- a/rust/kcl-derive-docs/tests/min.gen +++ b/rust/kcl-derive-docs/tests/min.gen @@ -32,13 +32,7 @@ mod test_examples_min { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_min0() -> miette::Result<()> { let code = "This is another code block.\nyes sirrr.\nmin"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/option.gen b/rust/kcl-derive-docs/tests/option.gen index e44a8c461..3441316c8 100644 --- a/rust/kcl-derive-docs/tests/option.gen +++ b/rust/kcl-derive-docs/tests/option.gen @@ -32,13 +32,7 @@ mod test_examples_show { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_show0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nshow"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/option_input_format.gen b/rust/kcl-derive-docs/tests/option_input_format.gen index b0c801e47..b6fb3b4bf 100644 --- a/rust/kcl-derive-docs/tests/option_input_format.gen +++ b/rust/kcl-derive-docs/tests/option_input_format.gen @@ -32,13 +32,7 @@ mod test_examples_import { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_import0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nimport"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/return_vec_box_sketch.gen b/rust/kcl-derive-docs/tests/return_vec_box_sketch.gen index 8a2d46da0..b7bc31f51 100644 --- a/rust/kcl-derive-docs/tests/return_vec_box_sketch.gen +++ b/rust/kcl-derive-docs/tests/return_vec_box_sketch.gen @@ -32,13 +32,7 @@ mod test_examples_import { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_import0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nimport"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/return_vec_sketch.gen b/rust/kcl-derive-docs/tests/return_vec_sketch.gen index 1501d992f..08c97efbd 100644 --- a/rust/kcl-derive-docs/tests/return_vec_sketch.gen +++ b/rust/kcl-derive-docs/tests/return_vec_sketch.gen @@ -32,13 +32,7 @@ mod test_examples_import { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_import0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nimport"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/show.gen b/rust/kcl-derive-docs/tests/show.gen index 00ae5ecdf..26aa3613b 100644 --- a/rust/kcl-derive-docs/tests/show.gen +++ b/rust/kcl-derive-docs/tests/show.gen @@ -32,13 +32,7 @@ mod test_examples_show { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_show0() -> miette::Result<()> { let code = "This is code.\nIt does other shit.\nshow"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-derive-docs/tests/test_args_with_exec_state.gen b/rust/kcl-derive-docs/tests/test_args_with_exec_state.gen index 6fa5ac694..ce8088a64 100644 --- a/rust/kcl-derive-docs/tests/test_args_with_exec_state.gen +++ b/rust/kcl-derive-docs/tests/test_args_with_exec_state.gen @@ -31,13 +31,7 @@ mod test_examples_some_function { #[tokio::test(flavor = "multi_thread", worker_threads = 5)] async fn kcl_test_example_some_function0() -> miette::Result<()> { let code = "someFunction()"; - let result = match crate::test_server::execute_and_snapshot( - code, - crate::settings::types::UnitLength::Mm, - None, - ) - .await - { + let result = match crate::test_server::execute_and_snapshot(code, None).await { Err(crate::errors::ExecError::Kcl(e)) => { return Err(miette::Report::new(crate::errors::Report { error: e.error, diff --git a/rust/kcl-lib/benches/benchmark_kcl_samples.rs b/rust/kcl-lib/benches/benchmark_kcl_samples.rs index 7f32df1ee..80a69a1f4 100644 --- a/rust/kcl-lib/benches/benchmark_kcl_samples.rs +++ b/rust/kcl-lib/benches/benchmark_kcl_samples.rs @@ -76,7 +76,7 @@ fn run_benchmarks(c: &mut Criterion) { group.bench_function(format!("execute_{}", dir_name), |b| { b.iter(|| { if let Err(err) = rt.block_on(async { - let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default()).await?; + let ctx = kcl_lib::ExecutorContext::new_with_default_client().await?; let mut exec_state = kcl_lib::ExecState::new(&ctx); ctx.run(black_box(&program), &mut exec_state).await?; ctx.close().await; diff --git a/rust/kcl-lib/e2e/executor/cache.rs b/rust/kcl-lib/e2e/executor/cache.rs index ff156e066..07e81cc28 100644 --- a/rust/kcl-lib/e2e/executor/cache.rs +++ b/rust/kcl-lib/e2e/executor/cache.rs @@ -51,45 +51,6 @@ async fn cache_test( img_results } -#[tokio::test(flavor = "multi_thread")] -async fn kcl_test_cache_change_units_changes_output() { - let code = r#"part001 = startSketchOn('XY') - |> startProfileAt([5.5229, 5.25217], %) - |> line(end = [10.50433, -1.19122]) - |> line(end = [8.01362, -5.48731]) - |> line(end = [-1.02877, -6.76825]) - |> line(end = [-11.53311, 2.81559]) - |> close() - |> extrude(length = 4) -"#; - - let result = cache_test( - "change_units_changes_output", - vec![ - Variation { - code, - settings: &kcl_lib::ExecutorSettings { - units: kcl_lib::UnitLength::In, - ..Default::default() - }, - }, - Variation { - code, - settings: &kcl_lib::ExecutorSettings { - units: kcl_lib::UnitLength::Mm, - ..Default::default() - }, - }, - ], - ) - .await; - - let first = result.first().unwrap(); - let second = result.last().unwrap(); - - assert!(first.1 != second.1); -} - #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cache_change_grid_visualizes_grid_off_to_on() { let code = r#"part001 = startSketchOn('XY') @@ -261,9 +222,7 @@ async fn kcl_test_cache_empty_file_pop_cache_empty_file_planes_work() { // Get the current working directory. let code = ""; - let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default()) - .await - .unwrap(); + let ctx = kcl_lib::ExecutorContext::new_with_default_client().await.unwrap(); let program = kcl_lib::Program::parse_no_errs(code).unwrap(); let outcome = ctx.run_with_caching(program).await.unwrap(); diff --git a/rust/kcl-lib/e2e/executor/inputs/cylinder-inches.kcl b/rust/kcl-lib/e2e/executor/inputs/cylinder-inches.kcl new file mode 100644 index 000000000..a23ac0b81 --- /dev/null +++ b/rust/kcl-lib/e2e/executor/inputs/cylinder-inches.kcl @@ -0,0 +1,4 @@ +@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) + |> circle(center = [0, 0], radius = 20) +extrude001 = extrude(sketch001, length = 10) diff --git a/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer-no-pipeExpr.kcl b/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer-no-pipeExpr.kcl index 1ee7bf174..66bbbdfb3 100644 --- a/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer-no-pipeExpr.kcl +++ b/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer-no-pipeExpr.kcl @@ -1,4 +1,5 @@ -const sketch001 = startSketchOn(XZ) +@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([75.8, 317.2], %) |> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine([ @@ -11,8 +12,8 @@ const sketch001 = startSketchOn(XZ) ], %, $yo) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> close() -const extrude001 = extrude(sketch001, length = 100) -const chamf = chamfer( +extrude001 = extrude(sketch001, length = 100) +chamf = chamfer( extrude001, length = 30, tags = [ diff --git a/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer.kcl b/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer.kcl index 30b0e8367..d36ebcf9e 100644 --- a/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer.kcl +++ b/rust/kcl-lib/e2e/executor/inputs/e2e-can-sketch-on-chamfer.kcl @@ -1,4 +1,5 @@ -const sketch001 = startSketchOn(XZ) +@settings(defaultLengthUnit = in) +sketch001 = startSketchOn(XZ) |> startProfileAt([75.8, 317.2], %) // [$startCapTag, $EndCapTag] |> angledLine([0, 268.43], %, $rectangleSegmentA001) |> angledLine([ @@ -11,7 +12,7 @@ const sketch001 = startSketchOn(XZ) ], %, $yo) |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) |> close() -const extrude001 = extrude(sketch001, length = 100) +extrude001 = extrude(sketch001, length = 100) |> chamfer( length = 30, tags = [ diff --git a/rust/kcl-lib/e2e/executor/main.rs b/rust/kcl-lib/e2e/executor/main.rs index 32f1759b6..327cb9ab3 100644 --- a/rust/kcl-lib/e2e/executor/main.rs +++ b/rust/kcl-lib/e2e/executor/main.rs @@ -2,7 +2,7 @@ mod cache; use kcl_lib::{ test_server::{execute_and_export_step, execute_and_snapshot, execute_and_snapshot_no_auth}, - ExecError, UnitLength, + ExecError, }; /// The minimum permissible difference between asserted twenty-twenty images. @@ -26,7 +26,7 @@ pub(crate) fn assert_out(test_name: &str, result: &image::DynamicImage) -> Strin async fn kcl_test_fillet_duplicate_tags() { let code = kcl_input!("fillet_duplicate_tags"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = result.expect_err("Code should have failed due to the duplicate edges being filletted"); let err = err.as_kcl_error().unwrap(); @@ -48,7 +48,7 @@ async fn kcl_test_execute_engine_error_return() { |> extrude(length = 4) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -61,7 +61,7 @@ async fn kcl_test_execute_i_shape() { // This is some code from lee that starts a pipe expression with a variable. let code = kcl_input!("i_shape"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("i_shape", &result); } @@ -70,7 +70,7 @@ async fn kcl_test_execute_i_shape() { async fn kcl_test_execute_pipes_on_pipes() { let code = kcl_input!("pipes_on_pipes"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("pipes_on_pipes", &result); } @@ -78,7 +78,7 @@ async fn kcl_test_execute_pipes_on_pipes() { async fn kcl_test_execute_cylinder() { let code = kcl_input!("cylinder"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cylinder", &result); } @@ -86,7 +86,7 @@ async fn kcl_test_execute_cylinder() { async fn kcl_test_execute_kittycad_svg() { let code = kcl_input!("kittycad_svg"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("kittycad_svg", &result); } @@ -94,7 +94,7 @@ async fn kcl_test_execute_kittycad_svg() { async fn kcl_test_execute_lsystem() { let code = kcl_input!("lsystem"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("lsystem", &result); } @@ -102,7 +102,7 @@ async fn kcl_test_execute_lsystem() { async fn kcl_test_member_expression_sketch() { let code = kcl_input!("member_expression_sketch"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("member_expression_sketch", &result); } @@ -110,7 +110,7 @@ async fn kcl_test_member_expression_sketch() { async fn kcl_test_helix_defaults() { let code = kcl_input!("helix_defaults"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("helix_defaults", &result); } @@ -118,7 +118,7 @@ async fn kcl_test_helix_defaults() { async fn kcl_test_helix_defaults_negative_extrude() { let code = kcl_input!("helix_defaults_negative_extrude"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("helix_defaults_negative_extrude", &result); } @@ -126,7 +126,7 @@ async fn kcl_test_helix_defaults_negative_extrude() { async fn kcl_test_helix_with_length() { let code = kcl_input!("helix_with_length"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("helix_with_length", &result); } @@ -134,7 +134,7 @@ async fn kcl_test_helix_with_length() { async fn kcl_test_dimensions_match() { let code = kcl_input!("dimensions_match"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("dimensions_match", &result); } @@ -142,7 +142,7 @@ async fn kcl_test_dimensions_match() { async fn kcl_test_close_arc() { let code = kcl_input!("close_arc"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("close_arc", &result); } @@ -150,7 +150,7 @@ async fn kcl_test_close_arc() { async fn kcl_test_negative_args() { let code = kcl_input!("negative_args"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("negative_args", &result); } @@ -164,7 +164,7 @@ async fn kcl_test_basic_tangential_arc_with_point() { |> extrude(length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("tangential_arc_with_point", &result); } @@ -178,7 +178,7 @@ async fn kcl_test_basic_tangential_arc_to() { |> extrude(length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("tangential_arc_to", &result); } @@ -205,7 +205,7 @@ box(30, 43, 18, '-xy') let thing = box(-12, -15, 10, 'yz') box(-20, -5, 10, 'xy')"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("different_planes_same_drawing", &result); } @@ -263,7 +263,7 @@ part004 = startSketchOn(YZ) |> close() "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("lots_of_planes", &result); } @@ -280,7 +280,7 @@ async fn kcl_test_holes() { |> extrude(length = 2) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("holes", &result); } @@ -299,7 +299,7 @@ async fn optional_params() { thing = other_circle([2, 2], 20) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("optional_params", &result); } @@ -335,7 +335,7 @@ part = roundedRectangle([0, 0], 20, 20, 4) |> extrude(length = 2) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("rounded_with_holes", &result); } @@ -343,7 +343,7 @@ part = roundedRectangle([0, 0], 20, 20, 4) async fn kcl_test_top_level_expression() { let code = r#"startSketchOn(XY) |> circle(center = [0,0], radius= 22) |> extrude(length = 14)"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("top_level_expression", &result); } @@ -357,7 +357,7 @@ part = startSketchOn(XY) |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic_with_math", &result); } @@ -369,7 +369,7 @@ async fn kcl_test_patterns_linear_basic() { |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic", &result); } @@ -385,7 +385,7 @@ async fn kcl_test_patterns_linear_basic_3d() { |> patternLinear3d(axis = [1, 0, 1], instances = 4, distance = 6) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic_3d", &result); } @@ -397,7 +397,7 @@ async fn kcl_test_patterns_linear_basic_negative_distance() { |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic_negative_distance", &result); } @@ -409,7 +409,7 @@ async fn kcl_test_patterns_linear_basic_negative_axis() { |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic_negative_axis", &result); } @@ -430,7 +430,7 @@ rectangle = startSketchOn(XY) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_linear_basic_holes", &result); } @@ -442,7 +442,7 @@ async fn kcl_test_patterns_circular_basic_2d() { |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_circular_basic_2d", &result); } @@ -458,7 +458,7 @@ async fn kcl_test_patterns_circular_basic_3d() { |> patternCircular3d(axis = [0,0, 1], center = [-20, -20, -20], instances = 41, arcDegrees = 360, rotateDuplicates = false) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_circular_basic_3d", &result); } @@ -474,7 +474,7 @@ async fn kcl_test_patterns_circular_3d_tilted_axis() { |> patternCircular3d(axis = [1,1,0], center = [10, 0, 10], instances = 11, arcDegrees = 360, rotateDuplicates = true) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("patterns_circular_3d_tilted_axis", &result); } @@ -483,7 +483,7 @@ async fn kcl_test_import_file_doesnt_exist() { let code = r#"import 'thing.obj' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -496,7 +496,7 @@ async fn kcl_test_import_obj_with_mtl() { let code = r#"import 'e2e/executor/inputs/cube.obj' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_obj_with_mtl", &result); } @@ -506,7 +506,7 @@ async fn kcl_test_import_obj_with_mtl_units() { import 'e2e/executor/inputs/cube.obj' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_obj_with_mtl_units", &result); } @@ -515,7 +515,7 @@ async fn kcl_test_import_stl() { let code = r#"import 'e2e/executor/inputs/2-5-long-m8-chc-screw.stl' as screw model = screw"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_stl", &result); } @@ -524,7 +524,7 @@ async fn kcl_test_import_gltf_with_bin() { let code = r#"import 'e2e/executor/inputs/cube.gltf' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_gltf_with_bin", &result); } @@ -533,7 +533,7 @@ async fn kcl_test_import_gltf_embedded() { let code = r#"import 'e2e/executor/inputs/cube-embedded.gltf' as cube model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_gltf_embedded", &result); } @@ -542,7 +542,7 @@ async fn kcl_test_import_glb() { let code = r#"import 'e2e/executor/inputs/cube.glb' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_glb", &result); } @@ -551,7 +551,7 @@ async fn kcl_test_import_glb_no_assign() { let code = r#"import 'e2e/executor/inputs/cube.glb' cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("import_glb_no_assign", &result); } @@ -561,7 +561,7 @@ async fn kcl_test_import_ext_doesnt_match() { import 'e2e/executor/inputs/cube.gltf' model = cube"#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -586,14 +586,15 @@ async fn kcl_test_cube_mm() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_mm", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cube_cm() { - let code = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) + let code = r#"@settings(defaultLengthUnit = cm) +fn cube = (pos, scale) => { + sg = startSketchOn('XY') |> startProfileAt(pos, %) |> line(end = [0, scale]) |> line(end = [scale, 0]) @@ -607,14 +608,15 @@ async fn kcl_test_cube_cm() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::Cm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_cm", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cube_m() { - let code = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) + let code = r#"@settings(defaultLengthUnit = m) +fn cube = (pos, scale) => { + sg = startSketchOn('XY') |> startProfileAt(pos, %) |> line(end = [0, scale]) |> line(end = [scale, 0]) @@ -628,14 +630,15 @@ async fn kcl_test_cube_m() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::M, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_m", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cube_in() { - let code = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) + let code = r#"@settings(defaultLengthUnit = in) +fn cube = (pos, scale) => { + sg = startSketchOn('XY') |> startProfileAt(pos, %) |> line(end = [0, scale]) |> line(end = [scale, 0]) @@ -649,14 +652,15 @@ async fn kcl_test_cube_in() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::In, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_in", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cube_ft() { - let code = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) + let code = r#"@settings(defaultLengthUnit = ft) +fn cube = (pos, scale) => { + sg = startSketchOn('XY') |> startProfileAt(pos, %) |> line(end = [0, scale]) |> line(end = [scale, 0]) @@ -670,14 +674,15 @@ async fn kcl_test_cube_ft() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::Ft, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_ft", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_cube_yd() { - let code = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) + let code = r#"@settings(defaultLengthUnit = yd) +fn cube = (pos, scale) => { + sg = startSketchOn('XY') |> startProfileAt(pos, %) |> line(end = [0, scale]) |> line(end = [scale, 0]) @@ -691,7 +696,7 @@ async fn kcl_test_cube_yd() { myCube = cube([0,0], 10) "#; - let result = execute_and_snapshot(code, UnitLength::Yd, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("cube_yd", &result); } @@ -719,7 +724,7 @@ part002 = startSketchOn(part001, part001.sketch.tags.here) |> extrude(length = 1) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = result.err().unwrap(); let ExecError::Kcl(err) = err else { @@ -763,7 +768,7 @@ part003 = startSketchOn(part002, "end") |> extrude(length = 5) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("sketch_on_face_of_face", &result); } @@ -780,7 +785,7 @@ async fn kcl_test_stdlib_kcl_error_right_code_path() { |> extrude(length = 2) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = result.err().unwrap(); let ExecError::Kcl(err) = err else { panic!("Expected KCL error, found {err}"); @@ -811,7 +816,7 @@ part002 = startSketchOn(part001, "end") |> extrude(length = 5) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("sketch_on_face_circle", &result); } @@ -853,7 +858,7 @@ part = rectShape([0, 0], 20, 20) ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = result.err().unwrap(); let ExecError::Kcl(err) = err else { panic!("Expected KCL error, found {err}"); @@ -880,7 +885,7 @@ async fn kcl_test_simple_revolve() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve", &result); } @@ -900,7 +905,7 @@ async fn kcl_test_simple_revolve_uppercase() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve_uppercase", &result); } @@ -920,7 +925,7 @@ async fn kcl_test_simple_revolve_negative() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve_negative", &result); } @@ -940,7 +945,7 @@ async fn kcl_test_revolve_bad_angle_low() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert!(result @@ -966,7 +971,7 @@ async fn kcl_test_revolve_bad_angle_high() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert!(result @@ -992,7 +997,7 @@ async fn kcl_test_simple_revolve_custom_angle() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve_custom_angle", &result); } @@ -1012,7 +1017,7 @@ async fn kcl_test_simple_revolve_custom_axis() { "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve_custom_axis", &result); } @@ -1036,7 +1041,7 @@ sketch001 = startSketchOn(box, "end") "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("revolve_on_edge", &result); } @@ -1060,7 +1065,7 @@ sketch001 = startSketchOn(box, revolveAxis) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; result.unwrap_err(); //this fails right now, but slightly differently, lets just say its enough for it to fail - mike @@ -1088,7 +1093,7 @@ sketch001 = startSketchOn(box, "END") ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("revolve_on_face_circle_edge", &result); } @@ -1110,7 +1115,7 @@ sketch001 = startSketchOn(box, "END") ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("revolve_on_face_circle", &result); } @@ -1136,7 +1141,7 @@ sketch001 = startSketchOn(box, "end") ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("revolve_on_face", &result); } @@ -1150,7 +1155,7 @@ async fn kcl_test_basic_revolve_circle() { ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("basic_revolve_circle", &result); } @@ -1177,7 +1182,7 @@ part002 = startSketchOn(part001, 'end') |> extrude(length = 5) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("simple_revolve_sketch_on_edge", &result); } @@ -1240,7 +1245,7 @@ plumbus1 = circle1 ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("plumbus_fillets", &result); } @@ -1248,7 +1253,7 @@ plumbus1 = circle1 async fn kcl_test_empty_file_is_ok() { let code = r#""#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; result.unwrap(); } @@ -1278,7 +1283,7 @@ async fn kcl_test_member_expression_in_params() { capScrew([0, 0.5, 0], 50, 37.5, 50, 25) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("member_expression_in_params", &result); } @@ -1323,7 +1328,7 @@ bracket = startSketchOn(XY) ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; result.unwrap(); } @@ -1343,7 +1348,7 @@ secondSketch = startSketchOn(part001, '') |> extrude(length = 20) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1374,7 +1379,7 @@ extrusion = startSketchOn(XY) |> extrude(length = height) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1407,7 +1412,7 @@ sketch001 = [profile001, profile002] extrude(sketch001, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("array_of_sketches", &result); } @@ -1444,7 +1449,7 @@ pattn1 = patternLinear3d( ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("pattern3d_array_of_extrudes", &result); } @@ -1492,7 +1497,7 @@ baseExtrusion = extrude(sketch001, length = width) ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("fillets_referencing_other_fillets", &result); } @@ -1540,7 +1545,7 @@ baseExtrusion = extrude(sketch001, length = width) ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("chamfers_referencing_other_chamfers", &result); } @@ -1560,7 +1565,7 @@ async fn kcl_test_shell_with_tag() { ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("shell_with_tag", &result); } @@ -1591,7 +1596,7 @@ pattn1 = patternLinear3d( ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("linear_pattern3d_filleted_sketch", &result); } @@ -1618,7 +1623,7 @@ pattn2 = patternCircular3d(part001, axis = [0,0, 1], center = [-20, -20, -20], i "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("circular_pattern3d_filleted_sketch", &result); } @@ -1644,7 +1649,7 @@ part001 = cube([0,0], 20) pattn2 = patternCircular3d(part001, axis = [0,0, 1], center = [-20, -20, -20], instances = 5, arcDegrees = 360, rotateDuplicates = false) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("circular_pattern3d_chamfered_sketch", &result); } @@ -1671,7 +1676,7 @@ part001 = cube([0,0], 20) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = result.err().unwrap(); let ExecError::Kcl(err) = err else { panic!("Expected KCL error, found {err}"); @@ -1701,7 +1706,7 @@ async fn kcl_test_duplicate_tags_should_error() { let p = triangle(200) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1712,49 +1717,49 @@ let p = triangle(200) #[tokio::test(flavor = "multi_thread")] async fn kcl_test_global_tags() { let code = kcl_input!("global-tags"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("global_tags", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_extrude_inside_fn_with_tags() { let code = kcl_input!("extrude-inside-fn-with-tags"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("extrude-inside-fn-with-tags", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_pattern_vase() { let code = kcl_input!("pattern_vase"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("pattern_vase", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_scoped_tags() { let code = kcl_input!("scoped-tags"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("scoped_tags", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_order_sketch_extrude_in_order() { let code = kcl_input!("order-sketch-extrude-in-order"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("order-sketch-extrude-in-order", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_order_sketch_extrude_out_of_order() { let code = kcl_input!("order-sketch-extrude-out-of-order"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("order-sketch-extrude-out-of-order", &result); } #[tokio::test(flavor = "multi_thread")] async fn kcl_test_extrude_custom_plane() { let code = kcl_input!("extrude-custom-plane"); - let result = execute_and_snapshot(code, UnitLength::Mm, None).await.unwrap(); + let result = execute_and_snapshot(code, None).await.unwrap(); assert_out("extrude-custom-plane", &result); } @@ -1776,7 +1781,7 @@ async fn kcl_test_arc_error_same_start_end() { ) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1796,7 +1801,7 @@ async fn kcl_test_angled_line_to_x_90() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1816,7 +1821,7 @@ async fn kcl_test_angled_line_to_x_270() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1836,7 +1841,7 @@ async fn kcl_test_angled_line_to_y_0() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1856,7 +1861,7 @@ async fn kcl_test_angled_line_to_y_180() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1876,7 +1881,7 @@ async fn kcl_test_angled_line_of_x_length_90() { extrusion = extrude(sketch001, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1896,7 +1901,7 @@ async fn kcl_test_angled_line_of_x_length_270() { extrusion = extrude(sketch001, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1918,7 +1923,7 @@ async fn kcl_test_angled_line_of_y_length_0() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1940,7 +1945,7 @@ async fn kcl_test_angled_line_of_y_length_180() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1962,7 +1967,7 @@ async fn kcl_test_angled_line_of_y_length_negative_180() { example = extrude(exampleSketch, length = 10) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -1979,7 +1984,7 @@ async fn kcl_test_error_inside_fn_also_has_source_range_of_call_site() { someFunction('INVALID') "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -2000,7 +2005,7 @@ async fn kcl_test_error_inside_fn_also_has_source_range_of_call_site_recursive() someFunction('INVALID') "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; assert!(result.is_err()); assert_eq!( result.err().unwrap().to_string(), @@ -2024,7 +2029,7 @@ async fn kcl_test_error_no_auth_websocket() { ) "#; - let result = execute_and_snapshot_no_auth(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot_no_auth(code, None).await; assert!(result.is_err()); assert!(result .err() @@ -2050,9 +2055,7 @@ sketch000 = startSketchOn(XY) |> line(end = [0, innerDiameter / 2]) "#; - let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default()) - .await - .unwrap(); + let ctx = kcl_lib::ExecutorContext::new_with_default_client().await.unwrap(); let mut exec_state = kcl_lib::ExecState::new(&ctx); let program = kcl_lib::Program::parse_no_errs(code).unwrap(); ctx.run(&program, &mut exec_state).await.unwrap(); @@ -2075,9 +2078,7 @@ async fn kcl_test_ensure_nothing_left_in_batch_multi_file() { // Change the current working directory to the test directory. std::env::set_current_dir(path.parent().unwrap()).unwrap(); - let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default()) - .await - .unwrap(); + let ctx = kcl_lib::ExecutorContext::new_with_default_client().await.unwrap(); let mut exec_state = kcl_lib::ExecState::new(&ctx); let program = kcl_lib::Program::parse_no_errs(&code).unwrap(); ctx.run(&program, &mut exec_state).await.unwrap(); @@ -2095,7 +2096,7 @@ async fn kcl_test_better_type_names() { |> circle(center = [-95.51, -74.7], radius = 262.23) |> appearance(metalness = 0.9) "#; - let result = execute_and_snapshot(code, UnitLength::Mm, None).await; + let result = execute_and_snapshot(code, None).await; let err = match result.err() { Some(x) => match x { @@ -2114,7 +2115,7 @@ async fn kcl_test_exporting_step_file() { // This tests export like how we do it in cli and kcl.py. let code = kcl_input!("helix_defaults_negative_extrude"); - let (_, _, files) = execute_and_export_step(code, UnitLength::Mm, None).await.unwrap(); + let (_, _, files) = execute_and_export_step(code, None).await.unwrap(); for file in files { expectorate::assert_contents( format!("e2e/executor/outputs/helix_defaults_negative_extrude_{}", file.name), diff --git a/rust/kcl-lib/src/docs/gen_std_tests.rs b/rust/kcl-lib/src/docs/gen_std_tests.rs index 475329a58..3702bd70a 100644 --- a/rust/kcl-lib/src/docs/gen_std_tests.rs +++ b/rust/kcl-lib/src/docs/gen_std_tests.rs @@ -1172,7 +1172,7 @@ fn find_examples(text: &str, filename: &str) -> Vec<(String, String)> { async fn run_example(text: &str) -> Result<()> { let program = crate::Program::parse_no_errs(text)?; - let ctx = ExecutorContext::new_with_default_client(crate::UnitLength::Mm).await?; + let ctx = ExecutorContext::new_with_default_client().await?; let mut exec_state = crate::execution::ExecState::new(&ctx); ctx.run(&program, &mut exec_state).await?; Ok(()) diff --git a/rust/kcl-lib/src/docs/kcl_doc.rs b/rust/kcl-lib/src/docs/kcl_doc.rs index fe78ddf2a..6fb2f1517 100644 --- a/rust/kcl-lib/src/docs/kcl_doc.rs +++ b/rust/kcl-lib/src/docs/kcl_doc.rs @@ -1010,20 +1010,17 @@ mod test { let std = walk_prelude(); for d in std { for (i, eg) in d.examples().enumerate() { - let result = - match crate::test_server::execute_and_snapshot(eg, crate::settings::types::UnitLength::Mm, None) - .await - { - Err(crate::errors::ExecError::Kcl(e)) => { - return Err(miette::Report::new(crate::errors::Report { - error: e.error, - filename: format!("{}{i}", d.name()), - kcl_source: eg.to_string(), - })); - } - Err(other_err) => panic!("{}", other_err), - Ok(img) => img, - }; + let result = match crate::test_server::execute_and_snapshot(eg, None).await { + Err(crate::errors::ExecError::Kcl(e)) => { + return Err(miette::Report::new(crate::errors::Report { + error: e.error, + filename: format!("{}{i}", d.name()), + kcl_source: eg.to_string(), + })); + } + Err(other_err) => panic!("{}", other_err), + Ok(img) => img, + }; twenty_twenty::assert_image( format!("tests/outputs/serial_test_example_{}{i}.png", d.example_name()), &result, diff --git a/rust/kcl-lib/src/engine/mod.rs b/rust/kcl-lib/src/engine/mod.rs index 3a2711850..6cef90c8e 100644 --- a/rust/kcl-lib/src/engine/mod.rs +++ b/rust/kcl-lib/src/engine/mod.rs @@ -176,6 +176,10 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static { ) .await?; + // Reset to the default units. Modules assume the engine starts in the + // default state. + self.set_units(Default::default(), source_range, id_generator).await?; + // Flush the batch queue, so clear is run right away. // Otherwise the hooks below won't work. self.flush_batch(false, source_range).await?; @@ -256,9 +260,6 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static { self.set_edge_visibility(settings.highlight_edges, source_range, id_generator) .await?; - // Change the units. - self.set_units(settings.units, source_range, id_generator).await?; - // Send the command to show the grid. self.modify_grid(!settings.show_grid, source_range, id_generator) .await?; diff --git a/rust/kcl-lib/src/execution/cache.rs b/rust/kcl-lib/src/execution/cache.rs index 33bc5cb36..b9c69a69f 100644 --- a/rust/kcl-lib/src/execution/cache.rs +++ b/rust/kcl-lib/src/execution/cache.rs @@ -97,15 +97,6 @@ pub(super) async fn get_changed_program(old: CacheInformation<'_>, new: CacheInf // If the settings are different we might need to bust the cache. // We specifically do this before checking if they are the exact same. if old.settings != new.settings { - // If the units are different we need to re-execute the whole thing. - if old.settings.units != new.settings.units { - return CacheResult::ReExecute { - clear_scene: true, - reapply_settings: true, - program: new.ast.clone(), - }; - } - // If anything else is different we may not need to re-execute, but rather just // run the settings again. reapply_settings = true; @@ -424,50 +415,6 @@ shell(firstSketch, faces = ['end'], thickness = 0.25)"#; assert_eq!(result, CacheResult::NoAction(false)); } - // Changing the units with the exact same file should bust the cache. - #[tokio::test(flavor = "multi_thread")] - async fn test_get_changed_program_same_code_but_different_units() { - let new = r#"// Remove the end face for the extrusion. -firstSketch = startSketchOn('XY') - |> startProfileAt([-12, 12], %) - |> line(end = [24, 0]) - |> line(end = [0, -24]) - |> line(end = [-24, 0]) - |> close() - |> extrude(length = 6) - -// Remove the end face for the extrusion. -shell(firstSketch, faces = ['end'], thickness = 0.25)"#; - - let ExecTestResults { - program, mut exec_ctxt, .. - } = parse_execute(new).await.unwrap(); - - // Change the settings to cm. - exec_ctxt.settings.units = crate::UnitLength::Cm; - - let result = get_changed_program( - CacheInformation { - ast: &program.ast, - settings: &Default::default(), - }, - CacheInformation { - ast: &program.ast, - settings: &exec_ctxt.settings, - }, - ) - .await; - - assert_eq!( - result, - CacheResult::ReExecute { - clear_scene: true, - reapply_settings: true, - program: program.ast - } - ); - } - // Changing the grid settings with the exact same file should NOT bust the cache. #[tokio::test(flavor = "multi_thread")] async fn test_get_changed_program_same_code_but_different_grid_setting() { @@ -615,4 +562,42 @@ startSketchOn('XY') } ); } + + // Removing the units settings using an annotation, when it was non-default + // units, with the exact same file should bust the cache. + #[tokio::test(flavor = "multi_thread")] + async fn test_get_changed_program_same_code_but_removed_unit_setting_using_annotation() { + let old_code = r#"@settings(defaultLengthUnit = in) +startSketchOn('XY') +"#; + let new_code = r#" +startSketchOn('XY') +"#; + + let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old_code).await.unwrap(); + + let mut new_program = crate::Program::parse_no_errs(new_code).unwrap(); + new_program.compute_digest(); + + let result = get_changed_program( + CacheInformation { + ast: &program.ast, + settings: &exec_ctxt.settings, + }, + CacheInformation { + ast: &new_program.ast, + settings: &exec_ctxt.settings, + }, + ) + .await; + + assert_eq!( + result, + CacheResult::ReExecute { + clear_scene: true, + reapply_settings: true, + program: new_program.ast + } + ); + } } diff --git a/rust/kcl-lib/src/execution/exec_ast.rs b/rust/kcl-lib/src/execution/exec_ast.rs index 5877889f8..415b011de 100644 --- a/rust/kcl-lib/src/execution/exec_ast.rs +++ b/rust/kcl-lib/src/execution/exec_ast.rs @@ -110,12 +110,7 @@ impl ExecutorContext { let old_units = exec_state.length_unit(); let original_execution = self.engine.replace_execution_kind(exec_kind).await; - let mut local_state = ModuleState::new( - &self.settings, - path.std_path(), - exec_state.stack().memory.clone(), - Some(module_id), - ); + let mut local_state = ModuleState::new(path.std_path(), exec_state.stack().memory.clone(), Some(module_id)); if !preserve_mem { std::mem::swap(&mut exec_state.mod_local, &mut local_state); } diff --git a/rust/kcl-lib/src/execution/mod.rs b/rust/kcl-lib/src/execution/mod.rs index be32e1de1..6a59856be 100644 --- a/rust/kcl-lib/src/execution/mod.rs +++ b/rust/kcl-lib/src/execution/mod.rs @@ -39,7 +39,6 @@ use crate::{ fs::FileManager, modules::{ModuleId, ModulePath}, parsing::ast::types::{Expr, ImportPath, NodeRef}, - settings::types::UnitLength, source_range::SourceRange, std::StdLib, CompilationError, ExecError, ExecutionKind, KclErrorWithOutputs, @@ -265,8 +264,6 @@ pub struct ExecutorContext { #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] #[ts(export)] pub struct ExecutorSettings { - /// The project-default unit to use in modeling dimensions. - pub units: UnitLength, /// Highlight edges of 3D objects? pub highlight_edges: bool, /// Whether or not Screen Space Ambient Occlusion (SSAO) is enabled. @@ -287,7 +284,6 @@ pub struct ExecutorSettings { impl Default for ExecutorSettings { fn default() -> Self { Self { - units: Default::default(), highlight_edges: true, enable_ssao: false, show_grid: false, @@ -301,7 +297,6 @@ impl Default for ExecutorSettings { impl From for ExecutorSettings { fn from(config: crate::settings::types::Configuration) -> Self { Self { - units: config.settings.modeling.base_unit, highlight_edges: config.settings.modeling.highlight_edges.into(), enable_ssao: config.settings.modeling.enable_ssao.into(), show_grid: config.settings.modeling.show_scale_grid, @@ -315,7 +310,6 @@ impl From for ExecutorSettings { impl From for ExecutorSettings { fn from(config: crate::settings::types::project::ProjectConfiguration) -> Self { Self { - units: config.settings.modeling.base_unit, highlight_edges: config.settings.modeling.highlight_edges.into(), enable_ssao: config.settings.modeling.enable_ssao.into(), show_grid: Default::default(), @@ -329,7 +323,6 @@ impl From for ExecutorSet impl From for ExecutorSettings { fn from(modeling: crate::settings::types::ModelingSettings) -> Self { Self { - units: modeling.base_unit, highlight_edges: modeling.highlight_edges.into(), enable_ssao: modeling.enable_ssao.into(), show_grid: modeling.show_scale_grid, @@ -343,7 +336,6 @@ impl From for ExecutorSettings { impl From for ExecutorSettings { fn from(modeling: crate::settings::types::project::ProjectModelingSettings) -> Self { Self { - units: modeling.base_unit, highlight_edges: modeling.highlight_edges.into(), enable_ssao: modeling.enable_ssao.into(), show_grid: Default::default(), @@ -476,26 +468,17 @@ impl ExecutorContext { /// This allows for passing in `ZOO_API_TOKEN` and `ZOO_HOST` as environment /// variables. #[cfg(not(target_arch = "wasm32"))] - pub async fn new_with_default_client(units: UnitLength) -> Result { + pub async fn new_with_default_client() -> Result { // Create the client. - let ctx = Self::new_with_client( - ExecutorSettings { - units, - ..Default::default() - }, - None, - None, - ) - .await?; + let ctx = Self::new_with_client(Default::default(), None, None).await?; Ok(ctx) } /// For executing unit tests. #[cfg(not(target_arch = "wasm32"))] - pub async fn new_for_unit_test(units: UnitLength, engine_addr: Option) -> Result { + pub async fn new_for_unit_test(engine_addr: Option) -> Result { let ctx = ExecutorContext::new_with_client( ExecutorSettings { - units, highlight_edges: true, enable_ssao: false, show_grid: false, @@ -862,11 +845,6 @@ impl ExecutorContext { Ok(()) } - /// Update the units for the executor. - pub(crate) fn update_units(&mut self, units: UnitLength) { - self.settings.units = units; - } - /// Get a snapshot of the current scene. pub async fn prepare_snapshot(&self) -> std::result::Result { // Zoom to fit. @@ -1008,11 +986,7 @@ mod tests { use pretty_assertions::assert_eq; use super::*; - use crate::{ - errors::{KclErrorDetails, Severity}, - execution::memory::Stack, - ModuleId, - }; + use crate::{errors::KclErrorDetails, execution::memory::Stack, ModuleId}; /// Convenience function to get a JSON value from memory and unwrap. #[track_caller] @@ -1615,34 +1589,6 @@ const inInches = 2.0 * inch()"#; ); } - #[tokio::test(flavor = "multi_thread")] - async fn test_unit_suggest() { - let src = "foo = 42"; - let program = crate::Program::parse_no_errs(src).unwrap(); - let ctx = ExecutorContext { - engine: Arc::new(Box::new( - crate::engine::conn_mock::EngineConnection::new().await.unwrap(), - )), - fs: Arc::new(crate::fs::FileManager::new()), - stdlib: Arc::new(crate::std::StdLib::new()), - settings: ExecutorSettings { - units: UnitLength::Ft, - ..Default::default() - }, - context_type: ContextType::Mock, - }; - let mut exec_state = ExecState::new(&ctx); - ctx.run(&program, &mut exec_state).await.unwrap(); - let errs = exec_state.errors(); - assert_eq!(errs.len(), 1, "{errs:?}"); - let warn = &errs[0]; - assert_eq!(warn.severity, Severity::Warning); - assert_eq!( - warn.apply_suggestion(src).unwrap(), - "@settings(defaultLengthUnit = ft)\nfoo = 42" - ) - } - #[tokio::test(flavor = "multi_thread")] async fn test_zero_param_fn() { let ast = r#"const sigmaAllow = 35000 // psi @@ -1971,9 +1917,7 @@ let w = f() + f() ) "#; - let ctx = crate::test_server::new_context(UnitLength::Mm, true, None) - .await - .unwrap(); + let ctx = crate::test_server::new_context(true, None).await.unwrap(); let old_program = crate::Program::parse_no_errs(code).unwrap(); // Execute the program. @@ -2026,9 +1970,7 @@ let w = f() + f() ) "#; - let mut ctx = crate::test_server::new_context(UnitLength::Mm, true, None) - .await - .unwrap(); + let mut ctx = crate::test_server::new_context(true, None).await.unwrap(); let old_program = crate::Program::parse_no_errs(code).unwrap(); // Execute the program. @@ -2066,7 +2008,7 @@ let w = f() + f() #[tokio::test(flavor = "multi_thread")] async fn mock_after_not_mock() { - let ctx = ExecutorContext::new_with_default_client(UnitLength::Mm).await.unwrap(); + let ctx = ExecutorContext::new_with_default_client().await.unwrap(); let program = crate::Program::parse_no_errs("x = 2").unwrap(); let result = ctx.run_with_caching(program).await.unwrap(); assert_eq!(result.variables.get("x").unwrap().as_f64().unwrap(), 2.0); diff --git a/rust/kcl-lib/src/execution/state.rs b/rust/kcl-lib/src/execution/state.rs index b094cfdaa..8c4561c47 100644 --- a/rust/kcl-lib/src/execution/state.rs +++ b/rust/kcl-lib/src/execution/state.rs @@ -82,7 +82,7 @@ impl ExecState { pub fn new(exec_context: &super::ExecutorContext) -> Self { ExecState { global: GlobalState::new(&exec_context.settings), - mod_local: ModuleState::new(&exec_context.settings, None, ProgramMemory::new(), Default::default()), + mod_local: ModuleState::new(None, ProgramMemory::new(), Default::default()), exec_context: Some(exec_context.clone()), } } @@ -92,7 +92,7 @@ impl ExecState { *self = ExecState { global, - mod_local: ModuleState::new(&exec_context.settings, None, ProgramMemory::new(), Default::default()), + mod_local: ModuleState::new(None, ProgramMemory::new(), Default::default()), exec_context: Some(exec_context.clone()), }; } @@ -289,12 +289,7 @@ impl GlobalState { } impl ModuleState { - pub(super) fn new( - exec_settings: &ExecutorSettings, - std_path: Option, - memory: Arc, - module_id: Option, - ) -> Self { + pub(super) fn new(std_path: Option, memory: Arc, module_id: Option) -> Self { ModuleState { id_generator: IdGenerator::new(module_id), stack: memory.new_stack(), @@ -303,14 +298,14 @@ impl ModuleState { explicit_length_units: false, std_path, settings: MetaSettings { - default_length_units: exec_settings.units.into(), + default_length_units: Default::default(), default_angle_units: Default::default(), }, } } } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS, JsonSchema)] #[ts(export)] #[serde(rename_all = "camelCase")] pub struct MetaSettings { diff --git a/rust/kcl-lib/src/lib.rs b/rust/kcl-lib/src/lib.rs index 953ec6dac..1d00d55ab 100644 --- a/rust/kcl-lib/src/lib.rs +++ b/rust/kcl-lib/src/lib.rs @@ -195,6 +195,10 @@ impl Program { }) } + pub fn is_empty_or_only_settings(&self) -> bool { + self.ast.is_empty_or_only_settings() + } + pub fn lint_all(&self) -> Result, anyhow::Error> { self.ast.lint_all() } diff --git a/rust/kcl-lib/src/lsp/kcl/mod.rs b/rust/kcl-lib/src/lsp/kcl/mod.rs index c3d77f822..465abce1b 100644 --- a/rust/kcl-lib/src/lsp/kcl/mod.rs +++ b/rust/kcl-lib/src/lsp/kcl/mod.rs @@ -812,56 +812,6 @@ impl Backend { Ok(()) } - pub async fn update_units( - &self, - params: custom_notifications::UpdateUnitsParams, - ) -> RpcResult> { - { - let mut ctx = self.executor_ctx.write().await; - // Borrow the executor context mutably. - let Some(ref mut executor_ctx) = *ctx else { - self.client - .log_message(MessageType::ERROR, "no executor context set to update units for") - .await; - return Ok(None); - }; - - self.client - .log_message(MessageType::INFO, format!("update units: {:?}", params)) - .await; - - if executor_ctx.settings.units == params.units - && !self.has_diagnostics(params.text_document.uri.as_ref()).await - { - // Return early the units are the same. - return Ok(None); - } - - // Set the engine units. - executor_ctx.update_units(params.units); - } - // Lock is dropped here since nested. - // This is IMPORTANT. - - let new_params = TextDocumentItem { - uri: params.text_document.uri.clone(), - text: std::mem::take(&mut params.text.to_string()), - version: Default::default(), - language_id: Default::default(), - }; - - // Force re-execution. - self.inner_on_change(new_params, true).await; - - // Check if we have diagnostics. - // If we do we return early, since we failed in some way. - if self.has_diagnostics(params.text_document.uri.as_ref()).await { - return Ok(None); - } - - Ok(Some(custom_notifications::UpdateUnitsResponse {})) - } - pub async fn update_can_execute( &self, params: custom_notifications::UpdateCanExecuteParams, diff --git a/rust/kcl-lib/src/lsp/test_util.rs b/rust/kcl-lib/src/lsp/test_util.rs index e757a3a28..3b8aa5011 100644 --- a/rust/kcl-lib/src/lsp/test_util.rs +++ b/rust/kcl-lib/src/lsp/test_util.rs @@ -42,7 +42,6 @@ pub async fn kcl_lsp_server(execute: bool) -> Result { can_execute: Arc::new(tokio::sync::RwLock::new(can_execute)), is_initialized: Default::default(), }) - .custom_method("kcl/updateUnits", crate::lsp::kcl::Backend::update_units) .custom_method("kcl/updateCanExecute", crate::lsp::kcl::Backend::update_can_execute) .finish(); diff --git a/rust/kcl-lib/src/lsp/tests.rs b/rust/kcl-lib/src/lsp/tests.rs index 08ec32058..bd871da38 100644 --- a/rust/kcl-lib/src/lsp/tests.rs +++ b/rust/kcl-lib/src/lsp/tests.rs @@ -2324,80 +2324,6 @@ async fn kcl_test_kcl_lsp_on_change_update_memory() { server.executor_ctx().await.clone().unwrap().close().await; } -#[tokio::test(flavor = "multi_thread", worker_threads = 10)] -async fn kcl_test_kcl_lsp_update_units() { - let server = kcl_lsp_server(true).await.unwrap(); - - let same_text = r#"fn cube = (pos, scale) => { - sg = startSketchOn(XY) - |> startProfileAt(pos, %) - |> line(end = [0, scale]) - |> line(end = [scale, 0]) - |> line(end = [0, -scale]) - - return sg -} -part001 = cube([0,0], 20) - |> close() - |> extrude(length = 20)"# - .to_string(); - - // Send open file. - server - .did_open(tower_lsp::lsp_types::DidOpenTextDocumentParams { - text_document: tower_lsp::lsp_types::TextDocumentItem { - uri: "file:///test.kcl".try_into().unwrap(), - language_id: "kcl".to_string(), - version: 1, - text: same_text.clone(), - }, - }) - .await; - - // Get the tokens. - let tokens = server.token_map.get("file:///test.kcl").unwrap().clone(); - assert_eq!(tokens.as_slice().len(), 123); - - // Get the ast. - let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); - assert_eq!(ast.ast.body.len(), 2); - - // Send change file. - server - .did_change(tower_lsp::lsp_types::DidChangeTextDocumentParams { - text_document: tower_lsp::lsp_types::VersionedTextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - version: 1, - }, - content_changes: vec![tower_lsp::lsp_types::TextDocumentContentChangeEvent { - range: None, - range_length: None, - text: same_text.clone(), - }], - }) - .await; - - let units = server.executor_ctx.read().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - - // Update the units. - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::M, - text: same_text.clone(), - }) - .await - .unwrap(); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::M); - - server.executor_ctx().await.clone().unwrap().close().await; -} - #[tokio::test(flavor = "multi_thread")] async fn kcl_test_kcl_lsp_empty_file_execute_ok() { let server = kcl_lsp_server(true).await.unwrap(); @@ -2733,145 +2659,6 @@ async fn kcl_test_kcl_lsp_code_and_ast_unchanged_but_has_diagnostics_reexecute() server.executor_ctx().await.clone().unwrap().close().await; } -#[tokio::test(flavor = "multi_thread")] -async fn kcl_test_kcl_lsp_code_and_ast_units_unchanged_but_has_diagnostics_reexecute_on_unit_change() { - let server = kcl_lsp_server(true).await.unwrap(); - - let code = r#"part001 = startSketchOn(XY) - |> startProfileAt([-10, -10], %) - |> line(end = [20, 0]) - |> line(end = [0, 20]) - |> line(end = [-20, 0]) - |> close() - |> extrude(length = 3.14)"#; - - // Send open file. - server - .did_open(tower_lsp::lsp_types::DidOpenTextDocumentParams { - text_document: tower_lsp::lsp_types::TextDocumentItem { - uri: "file:///test.kcl".try_into().unwrap(), - language_id: "kcl".to_string(), - version: 1, - text: code.to_string(), - }, - }) - .await; - - // Get the ast. - let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); - assert!(ast.ast != Node::::default()); - - // Assure we have no diagnostics. - assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 0); - - // Add some fake diagnostics. - server.diagnostics_map.insert( - "file:///test.kcl".to_string(), - vec![tower_lsp::lsp_types::Diagnostic { - range: tower_lsp::lsp_types::Range { - start: tower_lsp::lsp_types::Position { line: 0, character: 0 }, - end: tower_lsp::lsp_types::Position { line: 0, character: 0 }, - }, - message: "fake diagnostic".to_string(), - severity: Some(tower_lsp::lsp_types::DiagnosticSeverity::ERROR), - code: None, - source: None, - related_information: None, - tags: None, - data: None, - code_description: None, - }], - ); - // Assure we have one diagnostics. - assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 1); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - - // Update the units to the _same_ units. - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::Mm, - text: code.to_string(), - }) - .await - .unwrap(); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - - // Get the ast. - let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); - assert!(ast.ast != Node::::default()); - - // Assure we have no diagnostics. - assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 0); - - server.executor_ctx().await.clone().unwrap().close().await; -} - -#[tokio::test(flavor = "multi_thread")] -async fn kcl_test_kcl_lsp_code_and_ast_units_unchanged_but_has_memory_reexecute_on_unit_change() { - let server = kcl_lsp_server(true).await.unwrap(); - - let code = r#"part001 = startSketchOn(XY) - |> startProfileAt([-10, -10], %) - |> line(end = [20, 0]) - |> line(end = [0, 20]) - |> line(end = [-20, 0]) - |> close() - |> extrude(length = 3.14)"#; - - // Send open file. - server - .did_open(tower_lsp::lsp_types::DidOpenTextDocumentParams { - text_document: tower_lsp::lsp_types::TextDocumentItem { - uri: "file:///test.kcl".try_into().unwrap(), - language_id: "kcl".to_string(), - version: 1, - text: code.to_string(), - }, - }) - .await; - - // Get the ast. - let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); - assert!(ast.ast != Node::::default()); - - // Assure we have no diagnostics. - assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 0); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - - // Update the units to the _same_ units. - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::Mm, - text: code.to_string(), - }) - .await - .unwrap(); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - - // Get the ast. - let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); - assert!(ast.ast != Node::::default()); - - // Assure we have no diagnostics. - assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 0); - - server.executor_ctx().await.clone().unwrap().close().await; -} - #[tokio::test(flavor = "multi_thread")] async fn kcl_test_kcl_lsp_cant_execute_set() { let server = kcl_lsp_server(true).await.unwrap(); @@ -2903,23 +2690,6 @@ async fn kcl_test_kcl_lsp_cant_execute_set() { // Assure we have no diagnostics. assert_diagnostic_count(server.diagnostics_map.get("file:///test.kcl").as_deref(), 0); - // Update the units to the _same_ units. - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::Mm, - text: code.to_string(), - }) - .await - .unwrap(); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - // Get the ast. let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); assert!(ast.ast != Node::::default()); @@ -2936,23 +2706,6 @@ async fn kcl_test_kcl_lsp_cant_execute_set() { .unwrap(); assert_eq!(server.can_execute().await, false); - // Update the units to the _same_ units. - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::Mm, - text: code.to_string(), - }) - .await - .unwrap(); - - let units = server.executor_ctx().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - let mut default_hashed = Node::::default(); default_hashed.compute_digest(); @@ -2970,23 +2723,6 @@ async fn kcl_test_kcl_lsp_cant_execute_set() { .unwrap(); assert_eq!(server.can_execute().await, true); - // Update the units to the _same_ units. - let units = server.executor_ctx.read().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - server - .update_units(crate::lsp::kcl::custom_notifications::UpdateUnitsParams { - text_document: crate::lsp::kcl::custom_notifications::TextDocumentIdentifier { - uri: "file:///test.kcl".try_into().unwrap(), - }, - units: crate::settings::types::UnitLength::Mm, - text: code.to_string(), - }) - .await - .unwrap(); - - let units = server.executor_ctx.read().await.clone().unwrap().settings.units; - assert_eq!(units, crate::settings::types::UnitLength::Mm); - // Get the ast. let ast = server.ast_map.get("file:///test.kcl").unwrap().clone(); assert!(ast.ast != Node::::default()); diff --git a/rust/kcl-lib/src/parsing/ast/types/mod.rs b/rust/kcl-lib/src/parsing/ast/types/mod.rs index a10b9b074..f7938a293 100644 --- a/rust/kcl-lib/src/parsing/ast/types/mod.rs +++ b/rust/kcl-lib/src/parsing/ast/types/mod.rs @@ -369,6 +369,26 @@ impl Node { Ok(new_program) } + + /// Returns true if the given KCL is empty or only contains settings that + /// would be auto-generated. + pub fn is_empty_or_only_settings(&self) -> bool { + if !self.body.is_empty() { + return false; + } + + if self.non_code_meta.start_nodes.iter().any(|node| node.is_comment()) { + return false; + } + + for item in &self.inner_attrs { + if item.name() != Some(annotations::SETTINGS) { + return false; + } + } + + true + } } impl Program { @@ -3564,6 +3584,37 @@ mod tests { use super::*; + #[track_caller] + fn parse(code: &str) -> Node { + crate::parsing::top_level_parse(code).unwrap() + } + + #[test] + fn test_empty_or_only_settings() { + // Empty is empty. + assert!(parse("").is_empty_or_only_settings()); + + // Whitespace is empty. + assert!(parse(" ").is_empty_or_only_settings()); + + // Settings are empty. + assert!(parse(r#"@settings(defaultLengthUnit = mm)"#).is_empty_or_only_settings()); + + // Only comments is not empty. + assert!(!parse("// comment").is_empty_or_only_settings()); + + // Any statement is not empty. + assert!(!parse("5").is_empty_or_only_settings()); + + // Any statement is not empty, even with settings. + let code = r#"@settings(defaultLengthUnit = mm) +5"#; + assert!(!parse(code).is_empty_or_only_settings()); + + // Non-settings attributes are not empty. + assert!(!parse("@foo").is_empty_or_only_settings()); + } + // We have this as a test so we can ensure it never panics with an unwrap in the server. #[test] fn test_variable_kind_to_completion() { diff --git a/rust/kcl-lib/src/simulation_tests.rs b/rust/kcl-lib/src/simulation_tests.rs index 570e7bea5..30358e57f 100644 --- a/rust/kcl-lib/src/simulation_tests.rs +++ b/rust/kcl-lib/src/simulation_tests.rs @@ -155,13 +155,9 @@ async fn execute_test(test: &Test, render_to_png: bool, export_step: bool) { let ast = crate::Program::parse_no_errs(&input).unwrap(); // Run the program. - let exec_res = crate::test_server::execute_and_snapshot_ast( - ast, - crate::settings::types::UnitLength::Mm, - Some(test.input_dir.join(&test.entry_point)), - export_step, - ) - .await; + let exec_res = + crate::test_server::execute_and_snapshot_ast(ast, Some(test.input_dir.join(&test.entry_point)), export_step) + .await; match exec_res { Ok((exec_state, env_ref, png, step)) => { let fail_path = test.output_dir.join("execution_error.snap"); diff --git a/rust/kcl-lib/src/simulation_tests/kcl_samples.rs b/rust/kcl-lib/src/simulation_tests/kcl_samples.rs index fc30c4ebd..2f3b590ca 100644 --- a/rust/kcl-lib/src/simulation_tests/kcl_samples.rs +++ b/rust/kcl-lib/src/simulation_tests/kcl_samples.rs @@ -1,7 +1,7 @@ //! Run all the KCL samples in the `kcl_samples` directory. -use std::panic::{catch_unwind, AssertUnwindSafe}; use std::{ fs, + panic::{catch_unwind, AssertUnwindSafe}, path::{Path, PathBuf}, }; diff --git a/rust/kcl-lib/src/std/fillet.rs b/rust/kcl-lib/src/std/fillet.rs index 0aa08dfcc..e210fa690 100644 --- a/rust/kcl-lib/src/std/fillet.rs +++ b/rust/kcl-lib/src/std/fillet.rs @@ -165,7 +165,7 @@ async fn inner_fillet( edge_id, object_id: solid.id, radius: LengthUnit(radius), - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), cut_type: CutType::Fillet, // We make this a none so that we can remove it in the future. face_id: None, diff --git a/rust/kcl-lib/src/std/loft.rs b/rust/kcl-lib/src/std/loft.rs index dbe6b47c5..12fbffa54 100644 --- a/rust/kcl-lib/src/std/loft.rs +++ b/rust/kcl-lib/src/std/loft.rs @@ -159,7 +159,7 @@ async fn inner_loft( section_ids: sketches.iter().map(|group| group.id).collect(), base_curve_index, bez_approximate_rational, - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), v_degree, }), ) diff --git a/rust/kcl-lib/src/std/revolve.rs b/rust/kcl-lib/src/std/revolve.rs index 5a8b839d0..be811dbd0 100644 --- a/rust/kcl-lib/src/std/revolve.rs +++ b/rust/kcl-lib/src/std/revolve.rs @@ -273,7 +273,9 @@ async fn inner_revolve( target: sketch.id.into(), axis, origin, - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit( + tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into())), + ), axis_is_2d: true, }), ) @@ -287,7 +289,9 @@ async fn inner_revolve( angle, target: sketch.id.into(), edge_id, - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit( + tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into())), + ), }), ) .await?; diff --git a/rust/kcl-lib/src/std/sweep.rs b/rust/kcl-lib/src/std/sweep.rs index 3a00ceced..67dcb74db 100644 --- a/rust/kcl-lib/src/std/sweep.rs +++ b/rust/kcl-lib/src/std/sweep.rs @@ -191,7 +191,7 @@ async fn inner_sweep( target: sketch.id.into(), trajectory, sectional: sectional.unwrap_or(false), - tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))), + tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))), }), ) .await?; diff --git a/rust/kcl-lib/src/test_server.rs b/rust/kcl-lib/src/test_server.rs index e673743fc..baa72612e 100644 --- a/rust/kcl-lib/src/test_server.rs +++ b/rust/kcl-lib/src/test_server.rs @@ -6,7 +6,6 @@ use crate::{ engine::new_zoo_client, errors::ExecErrorWithState, execution::{EnvironmentRef, ExecState, ExecutorContext, ExecutorSettings}, - settings::types::UnitLength, ConnectionError, ExecError, KclError, KclErrorWithOutputs, Program, }; @@ -19,12 +18,8 @@ pub struct RequestBody { /// Executes a kcl program and takes a snapshot of the result. /// This returns the bytes of the snapshot. -pub async fn execute_and_snapshot( - code: &str, - units: UnitLength, - current_file: Option, -) -> Result { - let ctx = new_context(units, true, current_file).await?; +pub async fn execute_and_snapshot(code: &str, current_file: Option) -> Result { + let ctx = new_context(true, current_file).await?; let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?; let res = do_execute_and_snapshot(&ctx, program) .await @@ -38,11 +33,10 @@ pub async fn execute_and_snapshot( /// This returns the bytes of the snapshot. pub async fn execute_and_snapshot_ast( ast: Program, - units: UnitLength, current_file: Option, with_export_step: bool, ) -> Result<(ExecState, EnvironmentRef, image::DynamicImage, Option>), ExecErrorWithState> { - let ctx = new_context(units, true, current_file).await?; + let ctx = new_context(true, current_file).await?; let (exec_state, env, img) = do_execute_and_snapshot(&ctx, ast).await?; let mut step = None; if with_export_step { @@ -64,10 +58,9 @@ pub async fn execute_and_snapshot_ast( pub async fn execute_and_snapshot_no_auth( code: &str, - units: UnitLength, current_file: Option, ) -> Result<(image::DynamicImage, EnvironmentRef), ExecError> { - let ctx = new_context(units, false, current_file).await?; + let ctx = new_context(false, current_file).await?; let program = Program::parse_no_errs(code).map_err(KclErrorWithOutputs::no_outputs)?; let res = do_execute_and_snapshot(&ctx, program) .await @@ -111,11 +104,7 @@ async fn do_execute_and_snapshot( Ok((exec_state, result.0, img)) } -pub async fn new_context( - units: UnitLength, - with_auth: bool, - current_file: Option, -) -> Result { +pub async fn new_context(with_auth: bool, current_file: Option) -> Result { let mut client = new_zoo_client(if with_auth { None } else { Some("bad_token".to_string()) }, None) .map_err(ConnectionError::CouldNotMakeClient)?; if !with_auth { @@ -126,7 +115,6 @@ pub async fn new_context( } let mut settings = ExecutorSettings { - units, highlight_edges: true, enable_ssao: false, show_grid: false, @@ -145,7 +133,6 @@ pub async fn new_context( pub async fn execute_and_export_step( code: &str, - units: UnitLength, current_file: Option, ) -> Result< ( @@ -155,7 +142,7 @@ pub async fn execute_and_export_step( ), ExecErrorWithState, > { - let ctx = new_context(units, true, current_file).await?; + let ctx = new_context(true, current_file).await?; let mut exec_state = ExecState::new(&ctx); let program = Program::parse_no_errs(code) .map_err(|err| ExecErrorWithState::new(KclErrorWithOutputs::no_outputs(err).into(), exec_state.clone()))?; diff --git a/rust/kcl-lib/tests/add_lots/artifact_commands.snap b/rust/kcl-lib/tests/add_lots/artifact_commands.snap index 07281bef5..05627b96b 100644 --- a/rust/kcl-lib/tests/add_lots/artifact_commands.snap +++ b/rust/kcl-lib/tests/add_lots/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands add_lots.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/angled_line/artifact_commands.snap b/rust/kcl-lib/tests/angled_line/artifact_commands.snap index 0f8718b87..fb390e0a8 100644 --- a/rust/kcl-lib/tests/angled_line/artifact_commands.snap +++ b/rust/kcl-lib/tests/angled_line/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands angled_line.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/argument_error/artifact_commands.snap b/rust/kcl-lib/tests/argument_error/artifact_commands.snap index 8d6061bbf..3d416fbc9 100644 --- a/rust/kcl-lib/tests/argument_error/artifact_commands.snap +++ b/rust/kcl-lib/tests/argument_error/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands argument_error.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_elem_pop/artifact_commands.snap b/rust/kcl-lib/tests/array_elem_pop/artifact_commands.snap index 6d9771f65..4662a2462 100644 --- a/rust/kcl-lib/tests/array_elem_pop/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_elem_pop/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_elem_pop.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_elem_pop_empty_fail/artifact_commands.snap b/rust/kcl-lib/tests/array_elem_pop_empty_fail/artifact_commands.snap index 4f7e3f778..66c622616 100644 --- a/rust/kcl-lib/tests/array_elem_pop_empty_fail/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_elem_pop_empty_fail/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_elem_pop_empty_fail.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_elem_pop_fail/artifact_commands.snap b/rust/kcl-lib/tests/array_elem_pop_fail/artifact_commands.snap index ce918fec3..51d2c4462 100644 --- a/rust/kcl-lib/tests/array_elem_pop_fail/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_elem_pop_fail/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_elem_pop_fail.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_elem_push/artifact_commands.snap b/rust/kcl-lib/tests/array_elem_push/artifact_commands.snap index 53470d905..a58ce39dc 100644 --- a/rust/kcl-lib/tests/array_elem_push/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_elem_push/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_elem_push.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_elem_push_fail/artifact_commands.snap b/rust/kcl-lib/tests/array_elem_push_fail/artifact_commands.snap index 832fcd703..5548091ec 100644 --- a/rust/kcl-lib/tests/array_elem_push_fail/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_elem_push_fail/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_elem_push_fail.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_index_oob/artifact_commands.snap b/rust/kcl-lib/tests/array_index_oob/artifact_commands.snap index 0fee43e6b..861a45d1d 100644 --- a/rust/kcl-lib/tests/array_index_oob/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_index_oob/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_index_oob.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_range_expr/artifact_commands.snap b/rust/kcl-lib/tests/array_range_expr/artifact_commands.snap index 4bb6e7a01..438400004 100644 --- a/rust/kcl-lib/tests/array_range_expr/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_range_expr/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_range_expr.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/array_range_negative_expr/artifact_commands.snap b/rust/kcl-lib/tests/array_range_negative_expr/artifact_commands.snap index 19c77f9c7..81b821214 100644 --- a/rust/kcl-lib/tests/array_range_negative_expr/artifact_commands.snap +++ b/rust/kcl-lib/tests/array_range_negative_expr/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands array_range_negative_expr.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/artifact_graph_example_code1/artifact_commands.snap b/rust/kcl-lib/tests/artifact_graph_example_code1/artifact_commands.snap index ae9881c64..1233bb39c 100644 --- a/rust/kcl-lib/tests/artifact_graph_example_code1/artifact_commands.snap +++ b/rust/kcl-lib/tests/artifact_graph_example_code1/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands artifact_graph_example_code1.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/artifact_graph_example_code_no_3d/artifact_commands.snap b/rust/kcl-lib/tests/artifact_graph_example_code_no_3d/artifact_commands.snap index 36c8f32f3..aa7567355 100644 --- a/rust/kcl-lib/tests/artifact_graph_example_code_no_3d/artifact_commands.snap +++ b/rust/kcl-lib/tests/artifact_graph_example_code_no_3d/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands artifact_graph_example_code_no_3d.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/artifact_graph_example_code_offset_planes/artifact_commands.snap b/rust/kcl-lib/tests/artifact_graph_example_code_offset_planes/artifact_commands.snap index 2d3f249ec..bef87cefc 100644 --- a/rust/kcl-lib/tests/artifact_graph_example_code_offset_planes/artifact_commands.snap +++ b/rust/kcl-lib/tests/artifact_graph_example_code_offset_planes/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands artifact_graph_example_code_offset_planes.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/artifact_graph_sketch_on_face_etc/artifact_commands.snap b/rust/kcl-lib/tests/artifact_graph_sketch_on_face_etc/artifact_commands.snap index c9562c291..b16478f01 100644 --- a/rust/kcl-lib/tests/artifact_graph_sketch_on_face_etc/artifact_commands.snap +++ b/rust/kcl-lib/tests/artifact_graph_sketch_on_face_etc/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands artifact_graph_sketch_on_face_etc.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/assembly_mixed_units_cubes/artifact_commands.snap b/rust/kcl-lib/tests/assembly_mixed_units_cubes/artifact_commands.snap index ebed75783..4cf141630 100644 --- a/rust/kcl-lib/tests/assembly_mixed_units_cubes/artifact_commands.snap +++ b/rust/kcl-lib/tests/assembly_mixed_units_cubes/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands assembly_mixed_units_cubes.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/assembly_non_default_units/artifact_commands.snap b/rust/kcl-lib/tests/assembly_non_default_units/artifact_commands.snap index 8d0a44ccb..35d0f62ab 100644 --- a/rust/kcl-lib/tests/assembly_non_default_units/artifact_commands.snap +++ b/rust/kcl-lib/tests/assembly_non_default_units/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands assembly_non_default_units.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/bad_units_in_annotation/artifact_commands.snap b/rust/kcl-lib/tests/bad_units_in_annotation/artifact_commands.snap index 85f71544a..7ff70d0a1 100644 --- a/rust/kcl-lib/tests/bad_units_in_annotation/artifact_commands.snap +++ b/rust/kcl-lib/tests/bad_units_in_annotation/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands bad_units_in_annotation.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/basic_fillet_cube_close_opposite/artifact_commands.snap b/rust/kcl-lib/tests/basic_fillet_cube_close_opposite/artifact_commands.snap index a59a1e02e..db68c4afd 100644 --- a/rust/kcl-lib/tests/basic_fillet_cube_close_opposite/artifact_commands.snap +++ b/rust/kcl-lib/tests/basic_fillet_cube_close_opposite/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands basic_fillet_cube_close_opposite.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/basic_fillet_cube_end/artifact_commands.snap b/rust/kcl-lib/tests/basic_fillet_cube_end/artifact_commands.snap index 9077b89fe..26400b300 100644 --- a/rust/kcl-lib/tests/basic_fillet_cube_end/artifact_commands.snap +++ b/rust/kcl-lib/tests/basic_fillet_cube_end/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands basic_fillet_cube_end.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/basic_fillet_cube_next_adjacent/artifact_commands.snap b/rust/kcl-lib/tests/basic_fillet_cube_next_adjacent/artifact_commands.snap index fe0d4a7bf..651745e1d 100644 --- a/rust/kcl-lib/tests/basic_fillet_cube_next_adjacent/artifact_commands.snap +++ b/rust/kcl-lib/tests/basic_fillet_cube_next_adjacent/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands basic_fillet_cube_next_adjacent.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/basic_fillet_cube_previous_adjacent/artifact_commands.snap b/rust/kcl-lib/tests/basic_fillet_cube_previous_adjacent/artifact_commands.snap index cf4588ae6..5909434e8 100644 --- a/rust/kcl-lib/tests/basic_fillet_cube_previous_adjacent/artifact_commands.snap +++ b/rust/kcl-lib/tests/basic_fillet_cube_previous_adjacent/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands basic_fillet_cube_previous_adjacent.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/basic_fillet_cube_start/artifact_commands.snap b/rust/kcl-lib/tests/basic_fillet_cube_start/artifact_commands.snap index 9389d855b..3ce091a41 100644 --- a/rust/kcl-lib/tests/basic_fillet_cube_start/artifact_commands.snap +++ b/rust/kcl-lib/tests/basic_fillet_cube_start/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands basic_fillet_cube_start.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/big_number_angle_to_match_length_x/artifact_commands.snap b/rust/kcl-lib/tests/big_number_angle_to_match_length_x/artifact_commands.snap index 7070a10ba..7f9c6109a 100644 --- a/rust/kcl-lib/tests/big_number_angle_to_match_length_x/artifact_commands.snap +++ b/rust/kcl-lib/tests/big_number_angle_to_match_length_x/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands big_number_angle_to_match_length_x.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/big_number_angle_to_match_length_y/artifact_commands.snap b/rust/kcl-lib/tests/big_number_angle_to_match_length_y/artifact_commands.snap index 99e9a0dd5..eda9181f3 100644 --- a/rust/kcl-lib/tests/big_number_angle_to_match_length_y/artifact_commands.snap +++ b/rust/kcl-lib/tests/big_number_angle_to_match_length_y/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands big_number_angle_to_match_length_y.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/boolean_logical_and/artifact_commands.snap b/rust/kcl-lib/tests/boolean_logical_and/artifact_commands.snap index 902522491..9cd09307a 100644 --- a/rust/kcl-lib/tests/boolean_logical_and/artifact_commands.snap +++ b/rust/kcl-lib/tests/boolean_logical_and/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands boolean_logical_and.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/boolean_logical_multiple/artifact_commands.snap b/rust/kcl-lib/tests/boolean_logical_multiple/artifact_commands.snap index 78c0c63ed..a53ce5526 100644 --- a/rust/kcl-lib/tests/boolean_logical_multiple/artifact_commands.snap +++ b/rust/kcl-lib/tests/boolean_logical_multiple/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands boolean_logical_multiple.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/boolean_logical_or/artifact_commands.snap b/rust/kcl-lib/tests/boolean_logical_or/artifact_commands.snap index 4cd801e11..374262ba5 100644 --- a/rust/kcl-lib/tests/boolean_logical_or/artifact_commands.snap +++ b/rust/kcl-lib/tests/boolean_logical_or/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands boolean_logical_or.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/circle_three_point/artifact_commands.snap b/rust/kcl-lib/tests/circle_three_point/artifact_commands.snap index f57bf4e09..ae1e90596 100644 --- a/rust/kcl-lib/tests/circle_three_point/artifact_commands.snap +++ b/rust/kcl-lib/tests/circle_three_point/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands circle_three_point.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/circular_pattern3d_a_pattern/artifact_commands.snap b/rust/kcl-lib/tests/circular_pattern3d_a_pattern/artifact_commands.snap index 00e1f220f..bca7d582c 100644 --- a/rust/kcl-lib/tests/circular_pattern3d_a_pattern/artifact_commands.snap +++ b/rust/kcl-lib/tests/circular_pattern3d_a_pattern/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands circular_pattern3d_a_pattern.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/comparisons/artifact_commands.snap b/rust/kcl-lib/tests/comparisons/artifact_commands.snap index 3aa02f17a..4d84ea423 100644 --- a/rust/kcl-lib/tests/comparisons/artifact_commands.snap +++ b/rust/kcl-lib/tests/comparisons/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands comparisons.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/comparisons_multiple/artifact_commands.snap b/rust/kcl-lib/tests/comparisons_multiple/artifact_commands.snap index f3eabeea4..c7f2d8842 100644 --- a/rust/kcl-lib/tests/comparisons_multiple/artifact_commands.snap +++ b/rust/kcl-lib/tests/comparisons_multiple/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands comparisons_multiple.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/computed_var/artifact_commands.snap b/rust/kcl-lib/tests/computed_var/artifact_commands.snap index 040f1571b..5b4200403 100644 --- a/rust/kcl-lib/tests/computed_var/artifact_commands.snap +++ b/rust/kcl-lib/tests/computed_var/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands computed_var.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/crazy_multi_profile/artifact_commands.snap b/rust/kcl-lib/tests/crazy_multi_profile/artifact_commands.snap index 17dbe7722..403cfd8a8 100644 --- a/rust/kcl-lib/tests/crazy_multi_profile/artifact_commands.snap +++ b/rust/kcl-lib/tests/crazy_multi_profile/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands crazy_multi_profile.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/cube/artifact_commands.snap b/rust/kcl-lib/tests/cube/artifact_commands.snap index e9086ae16..f25d36f1c 100644 --- a/rust/kcl-lib/tests/cube/artifact_commands.snap +++ b/rust/kcl-lib/tests/cube/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands cube.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/cube_with_error/artifact_commands.snap b/rust/kcl-lib/tests/cube_with_error/artifact_commands.snap index 711c3f7c6..93b9411b9 100644 --- a/rust/kcl-lib/tests/cube_with_error/artifact_commands.snap +++ b/rust/kcl-lib/tests/cube_with_error/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands cube_with_error.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/double_map_fn/artifact_commands.snap b/rust/kcl-lib/tests/double_map_fn/artifact_commands.snap index 9fd3e7dba..1dbd81b6d 100644 --- a/rust/kcl-lib/tests/double_map_fn/artifact_commands.snap +++ b/rust/kcl-lib/tests/double_map_fn/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands double_map_fn.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/fillet-and-shell/artifact_commands.snap b/rust/kcl-lib/tests/fillet-and-shell/artifact_commands.snap index 392ae4bd9..e8a8c7f18 100644 --- a/rust/kcl-lib/tests/fillet-and-shell/artifact_commands.snap +++ b/rust/kcl-lib/tests/fillet-and-shell/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands fillet-and-shell.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/flush_batch_on_end/artifact_commands.snap b/rust/kcl-lib/tests/flush_batch_on_end/artifact_commands.snap index bd44e849e..5983766de 100644 --- a/rust/kcl-lib/tests/flush_batch_on_end/artifact_commands.snap +++ b/rust/kcl-lib/tests/flush_batch_on_end/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands flush_batch_on_end.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/function_sketch/artifact_commands.snap b/rust/kcl-lib/tests/function_sketch/artifact_commands.snap index af09bcdf9..3a741b800 100644 --- a/rust/kcl-lib/tests/function_sketch/artifact_commands.snap +++ b/rust/kcl-lib/tests/function_sketch/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands function_sketch.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/function_sketch_with_position/artifact_commands.snap b/rust/kcl-lib/tests/function_sketch_with_position/artifact_commands.snap index f1bbba0a5..c05b55d86 100644 --- a/rust/kcl-lib/tests/function_sketch_with_position/artifact_commands.snap +++ b/rust/kcl-lib/tests/function_sketch_with_position/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands function_sketch_with_position.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/helix_ccw/artifact_commands.snap b/rust/kcl-lib/tests/helix_ccw/artifact_commands.snap index d64456fa1..6b40a6102 100644 --- a/rust/kcl-lib/tests/helix_ccw/artifact_commands.snap +++ b/rust/kcl-lib/tests/helix_ccw/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands helix_ccw.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/helix_simple/artifact_commands.snap b/rust/kcl-lib/tests/helix_simple/artifact_commands.snap index 34c27f06d..2db09c2e7 100644 --- a/rust/kcl-lib/tests/helix_simple/artifact_commands.snap +++ b/rust/kcl-lib/tests/helix_simple/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands helix_simple.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/i_shape/artifact_commands.snap b/rust/kcl-lib/tests/i_shape/artifact_commands.snap index c733c4e44..3f7335fe8 100644 --- a/rust/kcl-lib/tests/i_shape/artifact_commands.snap +++ b/rust/kcl-lib/tests/i_shape/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands i_shape.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/if_else/artifact_commands.snap b/rust/kcl-lib/tests/if_else/artifact_commands.snap index 762e10c0b..a33ac287d 100644 --- a/rust/kcl-lib/tests/if_else/artifact_commands.snap +++ b/rust/kcl-lib/tests/if_else/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands if_else.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_constant/artifact_commands.snap b/rust/kcl-lib/tests/import_constant/artifact_commands.snap index 028aaffc2..78eeb4c8c 100644 --- a/rust/kcl-lib/tests/import_constant/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_constant/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_constant.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_cycle1/artifact_commands.snap b/rust/kcl-lib/tests/import_cycle1/artifact_commands.snap index 6dd19278b..0075075f7 100644 --- a/rust/kcl-lib/tests/import_cycle1/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_cycle1/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_cycle1.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_export/artifact_commands.snap b/rust/kcl-lib/tests/import_export/artifact_commands.snap index 36d9f17ec..7ac69634b 100644 --- a/rust/kcl-lib/tests/import_export/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_export/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_export.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_file_not_exist_error/artifact_commands.snap b/rust/kcl-lib/tests/import_file_not_exist_error/artifact_commands.snap index 54fb9c7d6..8b760a128 100644 --- a/rust/kcl-lib/tests/import_file_not_exist_error/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_file_not_exist_error/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_file_not_exist_error.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_file_parse_error/artifact_commands.snap b/rust/kcl-lib/tests/import_file_parse_error/artifact_commands.snap index a69103651..ff504f24c 100644 --- a/rust/kcl-lib/tests/import_file_parse_error/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_file_parse_error/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_file_parse_error.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_foreign/artifact_commands.snap b/rust/kcl-lib/tests/import_foreign/artifact_commands.snap index 484765b69..a7971688c 100644 --- a/rust/kcl-lib/tests/import_foreign/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_foreign/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_foreign.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_function_not_sketch/artifact_commands.snap b/rust/kcl-lib/tests/import_function_not_sketch/artifact_commands.snap index 4d2508cd3..f9fa43681 100644 --- a/rust/kcl-lib/tests/import_function_not_sketch/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_function_not_sketch/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_function_not_sketch.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_glob/artifact_commands.snap b/rust/kcl-lib/tests/import_glob/artifact_commands.snap index 8d6423f70..eb22fbbc5 100644 --- a/rust/kcl-lib/tests/import_glob/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_glob/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_glob.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_side_effect/artifact_commands.snap b/rust/kcl-lib/tests/import_side_effect/artifact_commands.snap index d92060f6b..a1e39f9d8 100644 --- a/rust/kcl-lib/tests/import_side_effect/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_side_effect/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_side_effect.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_transform/artifact_commands.snap b/rust/kcl-lib/tests/import_transform/artifact_commands.snap index 7eadb5e7a..3c4b223ca 100644 --- a/rust/kcl-lib/tests/import_transform/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_transform/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_transform.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/import_whole/artifact_commands.snap b/rust/kcl-lib/tests/import_whole/artifact_commands.snap index b0c86bfbd..d5018b761 100644 --- a/rust/kcl-lib/tests/import_whole/artifact_commands.snap +++ b/rust/kcl-lib/tests/import_whole/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands import_whole.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/index_of_array/artifact_commands.snap b/rust/kcl-lib/tests/index_of_array/artifact_commands.snap index 7bab36f3a..28adaa521 100644 --- a/rust/kcl-lib/tests/index_of_array/artifact_commands.snap +++ b/rust/kcl-lib/tests/index_of_array/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands index_of_array.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/intersect_cubes/artifact_commands.snap b/rust/kcl-lib/tests/intersect_cubes/artifact_commands.snap index 06ac34587..665c37255 100644 --- a/rust/kcl-lib/tests/intersect_cubes/artifact_commands.snap +++ b/rust/kcl-lib/tests/intersect_cubes/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands intersect_cubes.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/invalid_index_fractional/artifact_commands.snap b/rust/kcl-lib/tests/invalid_index_fractional/artifact_commands.snap index 8499f44b2..d1a70f78c 100644 --- a/rust/kcl-lib/tests/invalid_index_fractional/artifact_commands.snap +++ b/rust/kcl-lib/tests/invalid_index_fractional/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands invalid_index_fractional.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/invalid_index_negative/artifact_commands.snap b/rust/kcl-lib/tests/invalid_index_negative/artifact_commands.snap index 0670fda9a..3badb4d21 100644 --- a/rust/kcl-lib/tests/invalid_index_negative/artifact_commands.snap +++ b/rust/kcl-lib/tests/invalid_index_negative/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands invalid_index_negative.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/invalid_index_str/artifact_commands.snap b/rust/kcl-lib/tests/invalid_index_str/artifact_commands.snap index 0151c1417..2c5ba5365 100644 --- a/rust/kcl-lib/tests/invalid_index_str/artifact_commands.snap +++ b/rust/kcl-lib/tests/invalid_index_str/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands invalid_index_str.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/invalid_member_object/artifact_commands.snap b/rust/kcl-lib/tests/invalid_member_object/artifact_commands.snap index 765c4b0de..7070f1c03 100644 --- a/rust/kcl-lib/tests/invalid_member_object/artifact_commands.snap +++ b/rust/kcl-lib/tests/invalid_member_object/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands invalid_member_object.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/invalid_member_object_prop/artifact_commands.snap b/rust/kcl-lib/tests/invalid_member_object_prop/artifact_commands.snap index 547a828fa..9a82ca531 100644 --- a/rust/kcl-lib/tests/invalid_member_object_prop/artifact_commands.snap +++ b/rust/kcl-lib/tests/invalid_member_object_prop/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands invalid_member_object_prop.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/80-20-rail/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/80-20-rail/artifact_commands.snap index 6b43582ec..abdf82584 100644 --- a/rust/kcl-lib/tests/kcl_samples/80-20-rail/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/80-20-rail/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands 80-20-rail.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/a-parametric-bearing-pillow-block/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/a-parametric-bearing-pillow-block/artifact_commands.snap index cd45bdffe..b5e677798 100644 --- a/rust/kcl-lib/tests/kcl_samples/a-parametric-bearing-pillow-block/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/a-parametric-bearing-pillow-block/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands a-parametric-bearing-pillow-block.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/ball-bearing/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/ball-bearing/artifact_commands.snap index fc1012146..38bd16c17 100644 --- a/rust/kcl-lib/tests/kcl_samples/ball-bearing/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/ball-bearing/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands ball-bearing.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/bench/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/bench/artifact_commands.snap index d81c96b90..a9d90dc3a 100644 --- a/rust/kcl-lib/tests/kcl_samples/bench/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/bench/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands bench.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/bracket/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/bracket/artifact_commands.snap index e170b95b0..fa6610892 100644 --- a/rust/kcl-lib/tests/kcl_samples/bracket/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/bracket/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands bracket.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/car-wheel-assembly/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/car-wheel-assembly/artifact_commands.snap index 5df351670..279904952 100644 --- a/rust/kcl-lib/tests/kcl_samples/car-wheel-assembly/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/car-wheel-assembly/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands car-wheel-assembly.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/color-cube/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/color-cube/artifact_commands.snap index 7bcc0c8dc..5495016cb 100644 --- a/rust/kcl-lib/tests/kcl_samples/color-cube/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/color-cube/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands color-cube.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/cycloidal-gear/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/cycloidal-gear/artifact_commands.snap index b9f4e7e82..520e6ca80 100644 --- a/rust/kcl-lib/tests/kcl_samples/cycloidal-gear/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/cycloidal-gear/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands cycloidal-gear.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_commands.snap index f63b70153..53558e1ab 100644 --- a/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/dodecahedron/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands dodecahedron.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/dual-basin-utility-sink/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/dual-basin-utility-sink/artifact_commands.snap index c3240e555..507f89a8f 100644 --- a/rust/kcl-lib/tests/kcl_samples/dual-basin-utility-sink/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/dual-basin-utility-sink/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands dual-basin-utility-sink.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/enclosure/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/enclosure/artifact_commands.snap index 11a7529ad..334e24779 100644 --- a/rust/kcl-lib/tests/kcl_samples/enclosure/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/enclosure/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands enclosure.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/exhaust-manifold/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/exhaust-manifold/artifact_commands.snap index e7fea3b8a..4968f640a 100644 --- a/rust/kcl-lib/tests/kcl_samples/exhaust-manifold/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/exhaust-manifold/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands exhaust-manifold.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/flange/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/flange/artifact_commands.snap index 835610aa2..c13d2870a 100644 --- a/rust/kcl-lib/tests/kcl_samples/flange/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/flange/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands flange.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/focusrite-scarlett-mounting-bracket/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/focusrite-scarlett-mounting-bracket/artifact_commands.snap index bc02edbea..44bcedd6c 100644 --- a/rust/kcl-lib/tests/kcl_samples/focusrite-scarlett-mounting-bracket/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/focusrite-scarlett-mounting-bracket/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands focusrite-scarlett-mounting-bracket.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/food-service-spatula/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/food-service-spatula/artifact_commands.snap index 1538a9aa0..c20d6b22b 100644 --- a/rust/kcl-lib/tests/kcl_samples/food-service-spatula/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/food-service-spatula/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands food-service-spatula.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/french-press/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/french-press/artifact_commands.snap index 5508e13f0..3182990a1 100644 --- a/rust/kcl-lib/tests/kcl_samples/french-press/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/french-press/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands french-press.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gear-rack/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gear-rack/artifact_commands.snap index faf4d0f4c..f789357f8 100644 --- a/rust/kcl-lib/tests/kcl_samples/gear-rack/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gear-rack/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gear-rack.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gear/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gear/artifact_commands.snap index 70d533196..0097d3c9b 100644 --- a/rust/kcl-lib/tests/kcl_samples/gear/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gear/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gear.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate-magnets/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate-magnets/artifact_commands.snap index 44c76df75..7f7b50489 100644 --- a/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate-magnets/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate-magnets/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gridfinity-baseplate-magnets.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate/artifact_commands.snap index 84bf27b5a..2d73345a0 100644 --- a/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gridfinity-baseplate/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gridfinity-baseplate.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gridfinity-bins-stacking-lip/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gridfinity-bins-stacking-lip/artifact_commands.snap index abaa5ce87..d0566743f 100644 --- a/rust/kcl-lib/tests/kcl_samples/gridfinity-bins-stacking-lip/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gridfinity-bins-stacking-lip/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gridfinity-bins-stacking-lip.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/gridfinity-bins/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/gridfinity-bins/artifact_commands.snap index d03ddbd80..1698809ec 100644 --- a/rust/kcl-lib/tests/kcl_samples/gridfinity-bins/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/gridfinity-bins/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands gridfinity-bins.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/hex-nut/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/hex-nut/artifact_commands.snap index 27e46fe6a..906fc6cf7 100644 --- a/rust/kcl-lib/tests/kcl_samples/hex-nut/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/hex-nut/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands hex-nut.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/i-beam/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/i-beam/artifact_commands.snap index 3f41ea273..82ddc2934 100644 --- a/rust/kcl-lib/tests/kcl_samples/i-beam/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/i-beam/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands i-beam.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/keyboard/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/keyboard/artifact_commands.snap index 704efd8f5..b715a9bec 100644 --- a/rust/kcl-lib/tests/kcl_samples/keyboard/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/keyboard/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands keyboard.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/kitt/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/kitt/artifact_commands.snap index 31d5fbc5e..27f8b072f 100644 --- a/rust/kcl-lib/tests/kcl_samples/kitt/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/kitt/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kitt.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/lego/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/lego/artifact_commands.snap index 181d73a78..c00b95574 100644 --- a/rust/kcl-lib/tests/kcl_samples/lego/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/lego/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands lego.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/makeup-mirror/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/makeup-mirror/artifact_commands.snap index 714331e8b..938ecf4ba 100644 --- a/rust/kcl-lib/tests/kcl_samples/makeup-mirror/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/makeup-mirror/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands makeup-mirror.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/mounting-plate/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/mounting-plate/artifact_commands.snap index b034772b3..327e110dc 100644 --- a/rust/kcl-lib/tests/kcl_samples/mounting-plate/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/mounting-plate/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands mounting-plate.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/multi-axis-robot/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/multi-axis-robot/artifact_commands.snap index 5770ab7b0..8ad94c113 100644 --- a/rust/kcl-lib/tests/kcl_samples/multi-axis-robot/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/multi-axis-robot/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands multi-axis-robot.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/pipe-flange-assembly/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/pipe-flange-assembly/artifact_commands.snap index c344e925e..da1cccefb 100644 --- a/rust/kcl-lib/tests/kcl_samples/pipe-flange-assembly/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/pipe-flange-assembly/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pipe-flange-assembly.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/pipe-with-bend/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/pipe-with-bend/artifact_commands.snap index 669414905..adfbcf459 100644 --- a/rust/kcl-lib/tests/kcl_samples/pipe-with-bend/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/pipe-with-bend/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pipe-with-bend.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/pipe/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/pipe/artifact_commands.snap index a738d8abb..2a00a6cbd 100644 --- a/rust/kcl-lib/tests/kcl_samples/pipe/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/pipe/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pipe.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/poopy-shoe/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/poopy-shoe/artifact_commands.snap index 638fb7c64..a6175f25c 100644 --- a/rust/kcl-lib/tests/kcl_samples/poopy-shoe/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/poopy-shoe/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands poopy-shoe.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/router-template-cross-bar/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/router-template-cross-bar/artifact_commands.snap index 560ed4bf2..480854b6f 100644 --- a/rust/kcl-lib/tests/kcl_samples/router-template-cross-bar/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/router-template-cross-bar/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands router-template-cross-bar.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/router-template-slate/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/router-template-slate/artifact_commands.snap index 2fedc3b87..a1bc94bf9 100644 --- a/rust/kcl-lib/tests/kcl_samples/router-template-slate/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/router-template-slate/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands router-template-slate.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/sheet-metal-bracket/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/sheet-metal-bracket/artifact_commands.snap index c32759dd1..4816f9016 100644 --- a/rust/kcl-lib/tests/kcl_samples/sheet-metal-bracket/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/sheet-metal-bracket/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sheet-metal-bracket.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/socket-head-cap-screw/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/socket-head-cap-screw/artifact_commands.snap index 267e44d0c..b04405acf 100644 --- a/rust/kcl-lib/tests/kcl_samples/socket-head-cap-screw/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/socket-head-cap-screw/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands socket-head-cap-screw.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/walkie-talkie/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/walkie-talkie/artifact_commands.snap index e2eb2891c..a647e1932 100644 --- a/rust/kcl-lib/tests/kcl_samples/walkie-talkie/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/walkie-talkie/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands walkie-talkie.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kcl_samples/washer/artifact_commands.snap b/rust/kcl-lib/tests/kcl_samples/washer/artifact_commands.snap index 8b83f2e68..6e405f5a6 100644 --- a/rust/kcl-lib/tests/kcl_samples/washer/artifact_commands.snap +++ b/rust/kcl-lib/tests/kcl_samples/washer/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands washer.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kittycad_svg/artifact_commands.snap b/rust/kcl-lib/tests/kittycad_svg/artifact_commands.snap index 775f58ba4..2f0884759 100644 --- a/rust/kcl-lib/tests/kittycad_svg/artifact_commands.snap +++ b/rust/kcl-lib/tests/kittycad_svg/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kittycad_svg.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kw_fn/artifact_commands.snap b/rust/kcl-lib/tests/kw_fn/artifact_commands.snap index 544a4f7d4..6bbd1fc4e 100644 --- a/rust/kcl-lib/tests/kw_fn/artifact_commands.snap +++ b/rust/kcl-lib/tests/kw_fn/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kw_fn.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kw_fn_too_few_args/artifact_commands.snap b/rust/kcl-lib/tests/kw_fn_too_few_args/artifact_commands.snap index 8cf5dfd3e..1b849e3cc 100644 --- a/rust/kcl-lib/tests/kw_fn_too_few_args/artifact_commands.snap +++ b/rust/kcl-lib/tests/kw_fn_too_few_args/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kw_fn_too_few_args.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kw_fn_unlabeled_but_has_label/artifact_commands.snap b/rust/kcl-lib/tests/kw_fn_unlabeled_but_has_label/artifact_commands.snap index a3ee9277d..7f52f6ee2 100644 --- a/rust/kcl-lib/tests/kw_fn_unlabeled_but_has_label/artifact_commands.snap +++ b/rust/kcl-lib/tests/kw_fn_unlabeled_but_has_label/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kw_fn_unlabeled_but_has_label.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/kw_fn_with_defaults/artifact_commands.snap b/rust/kcl-lib/tests/kw_fn_with_defaults/artifact_commands.snap index 56a2d58c2..e604be4b8 100644 --- a/rust/kcl-lib/tests/kw_fn_with_defaults/artifact_commands.snap +++ b/rust/kcl-lib/tests/kw_fn_with_defaults/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands kw_fn_with_defaults.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/linear_pattern3d_a_pattern/artifact_commands.snap b/rust/kcl-lib/tests/linear_pattern3d_a_pattern/artifact_commands.snap index 572908ee2..071dc3c37 100644 --- a/rust/kcl-lib/tests/linear_pattern3d_a_pattern/artifact_commands.snap +++ b/rust/kcl-lib/tests/linear_pattern3d_a_pattern/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands linear_pattern3d_a_pattern.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/mike_stress_test/artifact_commands.snap b/rust/kcl-lib/tests/mike_stress_test/artifact_commands.snap index b6bd6ccc9..75ae6551f 100644 --- a/rust/kcl-lib/tests/mike_stress_test/artifact_commands.snap +++ b/rust/kcl-lib/tests/mike_stress_test/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands mike_stress_test.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/multi_transform/artifact_commands.snap b/rust/kcl-lib/tests/multi_transform/artifact_commands.snap index d1d0c82c0..a42d8a434 100644 --- a/rust/kcl-lib/tests/multi_transform/artifact_commands.snap +++ b/rust/kcl-lib/tests/multi_transform/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands multi_transform.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/neg_xz_plane/artifact_commands.snap b/rust/kcl-lib/tests/neg_xz_plane/artifact_commands.snap index a803f20d2..f76b9f0d4 100644 --- a/rust/kcl-lib/tests/neg_xz_plane/artifact_commands.snap +++ b/rust/kcl-lib/tests/neg_xz_plane/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands neg_xz_plane.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/non_string_key_of_object/artifact_commands.snap b/rust/kcl-lib/tests/non_string_key_of_object/artifact_commands.snap index 2e9335f3c..346495b20 100644 --- a/rust/kcl-lib/tests/non_string_key_of_object/artifact_commands.snap +++ b/rust/kcl-lib/tests/non_string_key_of_object/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands non_string_key_of_object.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/object_prop_not_found/artifact_commands.snap b/rust/kcl-lib/tests/object_prop_not_found/artifact_commands.snap index 2f4ee8596..1425055e3 100644 --- a/rust/kcl-lib/tests/object_prop_not_found/artifact_commands.snap +++ b/rust/kcl-lib/tests/object_prop_not_found/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands object_prop_not_found.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/out_of_band_sketches/artifact_commands.snap b/rust/kcl-lib/tests/out_of_band_sketches/artifact_commands.snap index c1f5ba1f1..f73f2f84a 100644 --- a/rust/kcl-lib/tests/out_of_band_sketches/artifact_commands.snap +++ b/rust/kcl-lib/tests/out_of_band_sketches/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands out_of_band_sketches.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/parametric/artifact_commands.snap b/rust/kcl-lib/tests/parametric/artifact_commands.snap index fbd4dfa29..964e9c8ad 100644 --- a/rust/kcl-lib/tests/parametric/artifact_commands.snap +++ b/rust/kcl-lib/tests/parametric/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands parametric.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/parametric_with_tan_arc/artifact_commands.snap b/rust/kcl-lib/tests/parametric_with_tan_arc/artifact_commands.snap index 4f4b60860..f7be42358 100644 --- a/rust/kcl-lib/tests/parametric_with_tan_arc/artifact_commands.snap +++ b/rust/kcl-lib/tests/parametric_with_tan_arc/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands parametric_with_tan_arc.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/pentagon_fillet_sugar/artifact_commands.snap b/rust/kcl-lib/tests/pentagon_fillet_sugar/artifact_commands.snap index f12fd872d..add89aa8d 100644 --- a/rust/kcl-lib/tests/pentagon_fillet_sugar/artifact_commands.snap +++ b/rust/kcl-lib/tests/pentagon_fillet_sugar/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pentagon_fillet_sugar.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/pipe_as_arg/artifact_commands.snap b/rust/kcl-lib/tests/pipe_as_arg/artifact_commands.snap index 9b89cbb3f..9b440bdd0 100644 --- a/rust/kcl-lib/tests/pipe_as_arg/artifact_commands.snap +++ b/rust/kcl-lib/tests/pipe_as_arg/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pipe_as_arg.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/pipe_substitution_inside_function_called_from_pipeline/artifact_commands.snap b/rust/kcl-lib/tests/pipe_substitution_inside_function_called_from_pipeline/artifact_commands.snap index 84d21eecd..8ab594fcb 100644 --- a/rust/kcl-lib/tests/pipe_substitution_inside_function_called_from_pipeline/artifact_commands.snap +++ b/rust/kcl-lib/tests/pipe_substitution_inside_function_called_from_pipeline/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands pipe_substitution_inside_function_called_from_pip "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/poop_chute/artifact_commands.snap b/rust/kcl-lib/tests/poop_chute/artifact_commands.snap index 37a8f580d..020bc0418 100644 --- a/rust/kcl-lib/tests/poop_chute/artifact_commands.snap +++ b/rust/kcl-lib/tests/poop_chute/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands poop_chute.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/property_of_object/artifact_commands.snap b/rust/kcl-lib/tests/property_of_object/artifact_commands.snap index fbe3e57a0..513d26c0b 100644 --- a/rust/kcl-lib/tests/property_of_object/artifact_commands.snap +++ b/rust/kcl-lib/tests/property_of_object/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands property_of_object.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/revolve_about_edge/artifact_commands.snap b/rust/kcl-lib/tests/revolve_about_edge/artifact_commands.snap index d6cb74271..e5d3120b8 100644 --- a/rust/kcl-lib/tests/revolve_about_edge/artifact_commands.snap +++ b/rust/kcl-lib/tests/revolve_about_edge/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands revolve_about_edge.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/riddle_small/artifact_commands.snap b/rust/kcl-lib/tests/riddle_small/artifact_commands.snap index 5fdc8f6c9..222b2b5f7 100644 --- a/rust/kcl-lib/tests/riddle_small/artifact_commands.snap +++ b/rust/kcl-lib/tests/riddle_small/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands riddle_small.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap index a94b0be47..8c18be435 100644 --- a/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap +++ b/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands rotate_after_fillet.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap index 5d911b59c..6e1139869 100644 --- a/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap +++ b/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands scale_after_fillet.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch-on-chamfer-two-times-different-order/artifact_commands.snap b/rust/kcl-lib/tests/sketch-on-chamfer-two-times-different-order/artifact_commands.snap index 6e036a30c..7b02e81ed 100644 --- a/rust/kcl-lib/tests/sketch-on-chamfer-two-times-different-order/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch-on-chamfer-two-times-different-order/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch-on-chamfer-two-times-different-order.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch-on-chamfer-two-times/artifact_commands.snap b/rust/kcl-lib/tests/sketch-on-chamfer-two-times/artifact_commands.snap index 6a6f00d85..0d3adf5aa 100644 --- a/rust/kcl-lib/tests/sketch-on-chamfer-two-times/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch-on-chamfer-two-times/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch-on-chamfer-two-times.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_in_object/artifact_commands.snap b/rust/kcl-lib/tests/sketch_in_object/artifact_commands.snap index c7fbc4106..c260a3a0d 100644 --- a/rust/kcl-lib/tests/sketch_in_object/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_in_object/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_in_object.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face/artifact_commands.snap index 7f733af2b..f37c2234b 100644 --- a/rust/kcl-lib/tests/sketch_on_face/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face_after_fillets_referencing_face/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face_after_fillets_referencing_face/artifact_commands.snap index b9c8b2e5a..f171056e3 100644 --- a/rust/kcl-lib/tests/sketch_on_face_after_fillets_referencing_face/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face_after_fillets_referencing_face/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face_after_fillets_referencing_face.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face_circle_tagged/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face_circle_tagged/artifact_commands.snap index a6839fac1..75da18b40 100644 --- a/rust/kcl-lib/tests/sketch_on_face_circle_tagged/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face_circle_tagged/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face_circle_tagged.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face_end/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face_end/artifact_commands.snap index ead803a03..a86e87380 100644 --- a/rust/kcl-lib/tests/sketch_on_face_end/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face_end/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face_end.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face_end_negative_extrude/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face_end_negative_extrude/artifact_commands.snap index 6fc2dd25b..9832f6e82 100644 --- a/rust/kcl-lib/tests/sketch_on_face_end_negative_extrude/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face_end_negative_extrude/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face_end_negative_extrude.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/sketch_on_face_start/artifact_commands.snap b/rust/kcl-lib/tests/sketch_on_face_start/artifact_commands.snap index 5699daa3e..ba5108432 100644 --- a/rust/kcl-lib/tests/sketch_on_face_start/artifact_commands.snap +++ b/rust/kcl-lib/tests/sketch_on_face_start/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands sketch_on_face_start.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/ssi_pattern/artifact_commands.snap b/rust/kcl-lib/tests/ssi_pattern/artifact_commands.snap index 2f5343f95..4d3ca26ce 100644 --- a/rust/kcl-lib/tests/ssi_pattern/artifact_commands.snap +++ b/rust/kcl-lib/tests/ssi_pattern/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands ssi_pattern.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/subtract_cylinder_from_cube/artifact_commands.snap b/rust/kcl-lib/tests/subtract_cylinder_from_cube/artifact_commands.snap index bb6a03ef3..86815f4f1 100644 --- a/rust/kcl-lib/tests/subtract_cylinder_from_cube/artifact_commands.snap +++ b/rust/kcl-lib/tests/subtract_cylinder_from_cube/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands subtract_cylinder_from_cube.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/tan_arc_x_line/artifact_commands.snap b/rust/kcl-lib/tests/tan_arc_x_line/artifact_commands.snap index c2c2b045c..3628827d6 100644 --- a/rust/kcl-lib/tests/tan_arc_x_line/artifact_commands.snap +++ b/rust/kcl-lib/tests/tan_arc_x_line/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands tan_arc_x_line.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/tangential_arc/artifact_commands.snap b/rust/kcl-lib/tests/tangential_arc/artifact_commands.snap index 5798d0d31..01e609007 100644 --- a/rust/kcl-lib/tests/tangential_arc/artifact_commands.snap +++ b/rust/kcl-lib/tests/tangential_arc/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands tangential_arc.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap index 5a51ad708..46afdef21 100644 --- a/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap +++ b/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands translate_after_fillet.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/union_cubes/artifact_commands.snap b/rust/kcl-lib/tests/union_cubes/artifact_commands.snap index 725a7ecef..4a790e730 100644 --- a/rust/kcl-lib/tests/union_cubes/artifact_commands.snap +++ b/rust/kcl-lib/tests/union_cubes/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands union_cubes.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-lib/tests/xz_plane/artifact_commands.snap b/rust/kcl-lib/tests/xz_plane/artifact_commands.snap index 7d289fd6c..7dc70cd21 100644 --- a/rust/kcl-lib/tests/xz_plane/artifact_commands.snap +++ b/rust/kcl-lib/tests/xz_plane/artifact_commands.snap @@ -11,14 +11,6 @@ description: Artifact commands xz_plane.kcl "hidden": false } }, - { - "cmdId": "[uuid]", - "range": [], - "command": { - "type": "set_scene_units", - "unit": "mm" - } - }, { "cmdId": "[uuid]", "range": [], diff --git a/rust/kcl-test-server/src/lib.rs b/rust/kcl-test-server/src/lib.rs index f23680119..308534269 100644 --- a/rust/kcl-test-server/src/lib.rs +++ b/rust/kcl-test-server/src/lib.rs @@ -15,7 +15,7 @@ use hyper::{ service::{make_service_fn, service_fn}, Body, Error, Response, Server, }; -use kcl_lib::{test_server::RequestBody, ExecState, ExecutorContext, Program, UnitLength}; +use kcl_lib::{test_server::RequestBody, ExecState, ExecutorContext, Program}; use tokio::{ sync::{mpsc, oneshot}, task::JoinHandle, @@ -69,9 +69,7 @@ fn start_worker(i: u8, engine_addr: Option) -> mpsc::Sender { // Make a work queue for this worker. let (tx, mut rx) = mpsc::channel(1); tokio::task::spawn(async move { - let state = ExecutorContext::new_for_unit_test(UnitLength::Mm, engine_addr) - .await - .unwrap(); + let state = ExecutorContext::new_for_unit_test(engine_addr).await.unwrap(); println!("Worker {i} ready"); while let Some(req) = rx.recv().await { let req: WorkerReq = req; diff --git a/rust/kcl-wasm-lib/src/lsp.rs b/rust/kcl-wasm-lib/src/lsp.rs index 1a5359c3d..79a5f807e 100644 --- a/rust/kcl-wasm-lib/src/lsp.rs +++ b/rust/kcl-wasm-lib/src/lsp.rs @@ -69,7 +69,6 @@ pub async fn lsp_run_kcl(config: LspServerConfig, token: String, baseurl: String let (service, socket) = LspService::build(|client| { kcl_lib::KclLspBackend::new_wasm(client, executor_ctx, fs, zoo_client, can_send_telemetry).unwrap() }) - .custom_method("kcl/updateUnits", kcl_lib::KclLspBackend::update_units) .custom_method("kcl/updateCanExecute", kcl_lib::KclLspBackend::update_can_execute) .finish(); diff --git a/rust/kcl-wasm-lib/src/wasm.rs b/rust/kcl-wasm-lib/src/wasm.rs index 74cc7f398..e9171e4fa 100644 --- a/rust/kcl-wasm-lib/src/wasm.rs +++ b/rust/kcl-wasm-lib/src/wasm.rs @@ -269,6 +269,17 @@ pub fn change_kcl_settings(code: &str, settings_str: &str) -> Result Result { + console_error_panic_hook::set_once(); + + let program = Program::parse_no_errs(code).map_err(|e| e.to_string())?; + + JsValue::from_serde(&program.is_empty_or_only_settings()).map_err(|e| e.to_string()) +} + /// Get the version of the kcl library. #[wasm_bindgen] pub fn get_kcl_version() -> String { diff --git a/src/components/CommandBarOverwriteWarning.tsx b/src/components/CommandBarOverwriteWarning.tsx index 9e9dd239f..1d5ac41f2 100644 --- a/src/components/CommandBarOverwriteWarning.tsx +++ b/src/components/CommandBarOverwriteWarning.tsx @@ -1,11 +1,11 @@ interface CommandBarOverwriteWarningProps { - heading?: string - message?: string + heading: string + message: string } export function CommandBarOverwriteWarning({ - heading = 'Overwrite current file and units?', - message = 'This will permanently replace the current code in the editor, and overwrite your current units.', + heading, + message, }: CommandBarOverwriteWarningProps) { return ( <> diff --git a/src/components/FileMachineProvider.tsx b/src/components/FileMachineProvider.tsx index 3d73b0ee4..1860d74d1 100644 --- a/src/components/FileMachineProvider.tsx +++ b/src/components/FileMachineProvider.tsx @@ -15,6 +15,7 @@ import { import { fileMachine } from 'machines/fileMachine' import { isDesktop } from 'lib/isDesktop' import { + DEFAULT_DEFAULT_LENGTH_UNIT, DEFAULT_FILE_NAME, DEFAULT_PROJECT_KCL_FILE, FILE_EXT, @@ -29,11 +30,12 @@ import { } from 'lib/getKclSamplesManifest' import { markOnce } from 'lib/performance' import { commandBarActor } from 'machines/commandBarMachine' -import { settingsActor, useSettings } from 'machines/appMachine' +import { useSettings } from 'machines/appMachine' import { createRouteCommands } from 'lib/commandBarConfigs/routeCommandConfig' import { useToken } from 'machines/appMachine' import { createNamedViewsCommand } from 'lib/commandBarConfigs/namedViewsConfig' -import { reportRejection } from 'lib/trap' +import { err, reportRejection } from 'lib/trap' +import { newKclFile } from 'lang/project' type MachineContext = { state: StateFrom @@ -237,7 +239,12 @@ export const FileMachineProvider = ({ createdPath ) } else { - await window.electron.writeFile(createdPath, input.content ?? '') + const codeToWrite = newKclFile( + input.content, + settings.modeling.defaultUnit.current + ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + await window.electron.writeFile(createdPath, codeToWrite) } } @@ -266,7 +273,12 @@ export const FileMachineProvider = ({ }) createdName = name createdPath = path - await window.electron.writeFile(createdPath, input.content ?? '') + const codeToWrite = newKclFile( + input.content, + settings.modeling.defaultUnit.current + ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + await window.electron.writeFile(createdPath, codeToWrite) } return { @@ -357,10 +369,16 @@ export const FileMachineProvider = ({ const hasKclEntries = entries.filter((e: string) => e.endsWith('.kcl')).length !== 0 if (!hasKclEntries) { - await window.electron.writeFile( - window.electron.path.join(project.path, DEFAULT_PROJECT_KCL_FILE), - '' + const codeToWrite = newKclFile( + undefined, + settings.modeling.defaultUnit.current ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + const path = window.electron.path.join( + project.path, + DEFAULT_PROJECT_KCL_FILE + ) + await window.electron.writeFile(path, codeToWrite) // Refresh the route selected above because it's possible we're on // the same path on the navigate, which doesn't cause anything to // refresh, leaving a stale execution state. @@ -401,7 +419,9 @@ export const FileMachineProvider = ({ authToken: token ?? '', projectData, settings: { - defaultUnit: settings.modeling.defaultUnit.current ?? 'mm', + defaultUnit: + settings.modeling.defaultUnit.current ?? + DEFAULT_DEFAULT_LENGTH_UNIT, }, specialPropsForSampleCommand: { onSubmit: async (data) => { @@ -419,18 +439,6 @@ export const FileMachineProvider = ({ }, }) } - - // Either way, we want to overwrite the defaultUnit project setting - // with the sample's setting. - if (data.sampleUnits) { - settingsActor.send({ - type: 'set.modeling.defaultUnit', - data: { - level: 'project', - value: data.sampleUnits, - }, - }) - } }, providedOptions: kclSamples.map((sample) => ({ value: sample.pathFromProjectDirectoryToFirstFile, diff --git a/src/components/ProjectsContextProvider.tsx b/src/components/ProjectsContextProvider.tsx index 176934b67..0c6559f98 100644 --- a/src/components/ProjectsContextProvider.tsx +++ b/src/components/ProjectsContextProvider.tsx @@ -32,6 +32,8 @@ import { } from 'lib/constants' import { codeManager, kclManager } from 'lib/singletons' import { Project } from 'lib/project' +import { newKclFile } from 'lang/project' +import { err } from 'lib/trap' type MachineContext = { state?: StateFrom @@ -120,7 +122,13 @@ const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => { createFile: fromPromise(async ({ input }) => { // Browser version doesn't navigate, just overwrites the current file clearImportSearchParams() - codeManager.updateCodeStateEditor(input.code || '') + + const codeToWrite = newKclFile( + input.code, + settings.modeling.defaultUnit.current + ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + codeManager.updateCodeStateEditor(codeToWrite) await codeManager.writeToFile() await kclManager.executeCode(true) @@ -388,8 +396,10 @@ const ProjectsContextDesktop = ({ } // Create the project around the file if newProject + let fileLoaded = false if (input.method === 'newProject') { await createNewProjectDirectory(projectName, input.code) + fileLoaded = true message = `Project "${projectName}" created successfully with link contents` } else { message = `File "${fileName}" created successfully` @@ -406,8 +416,16 @@ const ProjectsContextDesktop = ({ }) fileName = name - await window.electron.writeFile(path, input.code || '') + if (!fileLoaded) { + const codeToWrite = newKclFile( + input.code, + settings.modeling.defaultUnit.current + ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + await window.electron.writeFile(path, codeToWrite) + } + // TODO: Return the project's file name if one was created. return { message, fileName, diff --git a/src/components/UnitsMenu.tsx b/src/components/UnitsMenu.tsx index 57b23c11b..6be30d721 100644 --- a/src/components/UnitsMenu.tsx +++ b/src/components/UnitsMenu.tsx @@ -1,6 +1,11 @@ import { Popover } from '@headlessui/react' -import { settingsActor, useSettings } from 'machines/appMachine' -import { changeKclSettings, unitLengthToUnitLen } from 'lang/wasm' +import { + changeKclSettings, + unitAngleToUnitAng, + unitLengthToUnitLen, +} from 'lang/wasm' +import { DEFAULT_DEFAULT_ANGLE_UNIT } from 'lib/constants' +import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' import { baseUnitLabels, baseUnitsUnion } from 'lib/settings/settingsTypes' import { codeManager, kclManager } from 'lib/singletons' import { err, reportRejection } from 'lib/trap' @@ -8,24 +13,10 @@ import { useEffect, useState } from 'react' import toast from 'react-hot-toast' export function UnitsMenu() { - const settings = useSettings() - const [hasPerFileLengthUnit, setHasPerFileLengthUnit] = useState( - Boolean(kclManager.fileSettings.defaultLengthUnit) - ) - const [lengthSetting, setLengthSetting] = useState( - kclManager.fileSettings.defaultLengthUnit || - settings.modeling.defaultUnit.current - ) + const [fileSettings, setFileSettings] = useState(kclManager.fileSettings) useEffect(() => { - setHasPerFileLengthUnit(Boolean(kclManager.fileSettings.defaultLengthUnit)) - setLengthSetting( - kclManager.fileSettings.defaultLengthUnit || - settings.modeling.defaultUnit.current - ) - }, [ - kclManager.fileSettings.defaultLengthUnit, - settings.modeling.defaultUnit.current, - ]) + setFileSettings(kclManager.fileSettings) + }, [kclManager.fileSettings]) return ( @@ -41,7 +32,7 @@ export function UnitsMenu() {
Current units are:  - {lengthSetting} + {fileSettings.defaultLengthUnit ?? DEFAULT_DEFAULT_LENGTH_UNIT} { - if (hasPerFileLengthUnit) { - const newCode = changeKclSettings(codeManager.code, { - defaultLengthUnits: unitLengthToUnitLen(unit), - defaultAngleUnits: { type: 'Degrees' }, - }) - if (err(newCode)) { - toast.error( - `Failed to set per-file units: ${newCode.message}` - ) - } else { - codeManager.updateCodeStateEditor(newCode) - Promise.all([ - codeManager.writeToFile(), - kclManager.executeCode(), - ]) - .then(() => { - toast.success(`Updated per-file units to ${unit}`) - }) - .catch(reportRejection) - } + const newCode = changeKclSettings(codeManager.code, { + defaultLengthUnits: unitLengthToUnitLen(unit), + defaultAngleUnits: unitAngleToUnitAng( + fileSettings.defaultAngleUnit ?? + DEFAULT_DEFAULT_ANGLE_UNIT + ), + }) + if (err(newCode)) { + toast.error( + `Failed to set per-file units: ${newCode.message}` + ) } else { - settingsActor.send({ - type: 'set.modeling.defaultUnit', - data: { - level: 'project', - value: unit, - }, - }) + codeManager.updateCodeStateEditor(newCode) + Promise.all([ + codeManager.writeToFile(), + kclManager.executeCode(), + ]) + .then(() => { + toast.success(`Updated per-file units to ${unit}`) + }) + .catch(reportRejection) } close() }} > {baseUnitLabels[unit]} - {unit === lengthSetting && ( + {unit === + (fileSettings.defaultLengthUnit ?? + DEFAULT_DEFAULT_LENGTH_UNIT) && ( current )} diff --git a/src/lang/project.ts b/src/lang/project.ts new file mode 100644 index 000000000..17141a034 --- /dev/null +++ b/src/lang/project.ts @@ -0,0 +1,33 @@ +import { UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' +import { + changeKclSettings, + unitAngleToUnitAng, + unitLengthToUnitLen, +} from './wasm' +import { DEFAULT_DEFAULT_ANGLE_UNIT } from 'lib/constants' +import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' + +/** + * Create a new KCL file with the given initial content and default length unit. + * @returns KCL string + */ +export function newKclFile( + initialContent: string | undefined, + defaultLengthUnit: UnitLength +): string | Error { + // If we're given initial content, we're loading a file that should already + // have units in it. Don't modify it. + if (initialContent !== undefined) { + return initialContent + } + // If the default length unit is the same as the default default length unit, + // there's no need to add the attribute. + if (defaultLengthUnit === DEFAULT_DEFAULT_LENGTH_UNIT) { + return '' + } + + return changeKclSettings('', { + defaultLengthUnits: unitLengthToUnitLen(defaultLengthUnit), + defaultAngleUnits: unitAngleToUnitAng(DEFAULT_DEFAULT_ANGLE_UNIT), + }) +} diff --git a/src/lang/wasm.ts b/src/lang/wasm.ts index 3cfe0950f..df3d6c235 100644 --- a/src/lang/wasm.ts +++ b/src/lang/wasm.ts @@ -18,6 +18,7 @@ import { serialize_project_configuration, serialize_configuration, reloadModule, + is_kcl_empty_or_only_settings, } from 'lib/wasm_lib_wrapper' import { KCLError } from './errors' @@ -55,6 +56,10 @@ import { UnitAngle as UnitAng } from '@rust/kcl-lib/bindings/UnitAngle' import { ModulePath } from '@rust/kcl-lib/bindings/ModulePath' import { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes' import { isArray } from 'lib/utils' +import { + DEFAULT_DEFAULT_ANGLE_UNIT, + DEFAULT_DEFAULT_LENGTH_UNIT, +} from 'lib/constants' export type { Artifact } from '@rust/kcl-lib/bindings/Artifact' export type { ArtifactCommand } from '@rust/kcl-lib/bindings/Artifact' @@ -607,7 +612,27 @@ export function changeKclSettings( } /** - * Convert a `UnitLength_type` to a `UnitLen` + * Returns true if the given KCL is empty or only contains settings that would + * be auto-generated. + */ +export function isKclEmptyOrOnlySettings(kcl: string): boolean { + if (kcl === '') { + // Fast path. + return true + } + + try { + return is_kcl_empty_or_only_settings(kcl) + } catch (e) { + console.debug('Caught error checking if KCL is empty', e) + // If there's a parse error, it can't be empty or auto-generated. + return false + } +} + +/** + * Convert a `UnitLength` (used in settings and modeling commands) to a + * `UnitLen` (used in execution). */ export function unitLengthToUnitLen(input: UnitLength): UnitLen { switch (input) { @@ -627,7 +652,8 @@ export function unitLengthToUnitLen(input: UnitLength): UnitLen { } /** - * Convert `UnitLen` to `UnitLength_type`. + * Convert `UnitLen` (used in execution) to `UnitLength` (used in settings + * and modeling commands). */ export function unitLenToUnitLength(input: UnitLen): UnitLength { switch (input.type) { @@ -642,19 +668,33 @@ export function unitLenToUnitLength(input: UnitLen): UnitLength { case 'Inches': return 'in' default: - return 'mm' + return DEFAULT_DEFAULT_LENGTH_UNIT } } /** - * Convert `UnitAngle` to `UnitAngle_type`. + * Convert a `UnitAngle` (used in modeling commands) to a `UnitAng` (used in + * execution). + */ +export function unitAngleToUnitAng(input: UnitAngle): UnitAng { + switch (input) { + case 'radians': + return { type: 'Radians' } + default: + return { type: 'Degrees' } + } +} + +/** + * Convert `UnitAng` (used in execution) to `UnitAngle` (used in modeling + * commands). */ export function unitAngToUnitAngle(input: UnitAng): UnitAngle { switch (input.type) { case 'Radians': return 'radians' default: - return 'degrees' + return DEFAULT_DEFAULT_ANGLE_UNIT } } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 2007ba35b..3731990b0 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,4 +1,5 @@ import { Models } from '@kittycad/lib/dist/types/src' +import { UnitAngle, UnitLength } from '@rust/kcl-lib/bindings/ModelingCmd' export const APP_NAME = 'Modeling App' /** Search string in new project names to increment as an index */ @@ -168,6 +169,18 @@ export const ZOO_STUDIO_PROTOCOL = 'zoo-studio' */ export const ASK_TO_OPEN_QUERY_PARAM = 'ask-open-desktop' +/** + * When no annotation is in the KCL file to specify the defaults, we use these + * default units. + */ +export const DEFAULT_DEFAULT_ANGLE_UNIT: UnitAngle = 'degrees' + +/** + * When no annotation is in the KCL file to specify the defaults, we use these + * default units. + */ +export const DEFAULT_DEFAULT_LENGTH_UNIT: UnitLength = 'mm' + /** Real execution. */ export const EXECUTION_TYPE_REAL = 'real' /** Mock execution. */ diff --git a/src/lib/desktop.ts b/src/lib/desktop.ts index f154b9308..0b591d117 100644 --- a/src/lib/desktop.ts +++ b/src/lib/desktop.ts @@ -9,6 +9,7 @@ import { parseProjectSettings, } from 'lang/wasm' import { + DEFAULT_DEFAULT_LENGTH_UNIT, PROJECT_ENTRYPOINT, PROJECT_FOLDER, PROJECT_IMAGE_NAME, @@ -21,6 +22,7 @@ import { import { DeepPartial } from './types' import { ProjectConfiguration } from '@rust/kcl-lib/bindings/ProjectConfiguration' import { Configuration } from '@rust/kcl-lib/bindings/Configuration' +import { newKclFile } from 'lang/project' export async function renameProjectDirectory( projectPath: string, @@ -113,7 +115,15 @@ export async function createNewProjectDirectory( } const projectFile = window.electron.path.join(projectDir, PROJECT_ENTRYPOINT) - await window.electron.writeFile(projectFile, initialCode ?? '') + // When initialCode is present, we're loading existing code. If it's not + // present, we're creating a new project, and we want to incorporate the + // user's settings. + const codeToWrite = newKclFile( + initialCode, + configuration?.settings?.modeling?.base_unit ?? DEFAULT_DEFAULT_LENGTH_UNIT + ) + if (err(codeToWrite)) return Promise.reject(codeToWrite) + await window.electron.writeFile(projectFile, codeToWrite) const metadata = await window.electron.stat(projectFile) return { diff --git a/src/lib/kclCommands.ts b/src/lib/kclCommands.ts index f8c478627..923c24202 100644 --- a/src/lib/kclCommands.ts +++ b/src/lib/kclCommands.ts @@ -2,11 +2,22 @@ import { CommandBarOverwriteWarning } from 'components/CommandBarOverwriteWarnin import { Command, CommandArgumentOption } from './commandTypes' import { codeManager, kclManager } from './singletons' import { isDesktop } from './isDesktop' -import { FILE_EXT } from './constants' +import { + DEFAULT_DEFAULT_ANGLE_UNIT, + DEFAULT_DEFAULT_LENGTH_UNIT, + FILE_EXT, +} from './constants' import { UnitLength_type } from '@kittycad/lib/dist/types/src/models' -import { reportRejection } from './trap' +import { err, reportRejection } from './trap' import { IndexLoaderData } from './types' import { copyFileShareLink } from './links' +import { baseUnitsUnion } from './settings/settingsTypes' +import toast from 'react-hot-toast' +import { + changeKclSettings, + unitLengthToUnitLen, + unitAngleToUnitAng, +} from 'lang/wasm' interface OnSubmitProps { sampleName: string @@ -31,6 +42,59 @@ interface KclCommandConfig { export function kclCommands(commandProps: KclCommandConfig): Command[] { return [ + { + name: 'set-file-units', + displayName: 'Set file units', + description: + 'Set the length unit for all dimensions not given explicit units in the current file.', + needsReview: false, + groupId: 'code', + icon: 'code', + args: { + unit: { + required: true, + inputType: 'options', + defaultValue: + kclManager.fileSettings.defaultLengthUnit || + DEFAULT_DEFAULT_LENGTH_UNIT, + options: () => + Object.values(baseUnitsUnion).map((v) => { + return { + name: v, + value: v, + isCurrent: kclManager.fileSettings.defaultLengthUnit + ? v === kclManager.fileSettings.defaultLengthUnit + : v === DEFAULT_DEFAULT_LENGTH_UNIT, + } + }), + }, + }, + onSubmit: (data) => { + if (typeof data === 'object' && 'unit' in data) { + const newCode = changeKclSettings(codeManager.code, { + defaultLengthUnits: unitLengthToUnitLen(data.unit), + defaultAngleUnits: unitAngleToUnitAng( + kclManager.fileSettings.defaultAngleUnit ?? + DEFAULT_DEFAULT_ANGLE_UNIT + ), + }) + if (err(newCode)) { + toast.error(`Failed to set per-file units: ${newCode.message}`) + } else { + codeManager.updateCodeStateEditor(newCode) + Promise.all([codeManager.writeToFile(), kclManager.executeCode()]) + .then(() => { + toast.success(`Updated per-file units to ${data.unit}`) + }) + .catch(reportRejection) + } + } else { + toast.error( + 'Failed to set per-file units: no value provided to submit function. This is a bug.' + ) + } + }, + }, { name: 'format-code', displayName: 'Format Code', @@ -49,12 +113,18 @@ export function kclCommands(commandProps: KclCommandConfig): Command[] { needsReview: true, icon: 'code', reviewMessage: ({ argumentsToSubmit }) => - argumentsToSubmit.method === 'newFile' - ? CommandBarOverwriteWarning({ - heading: 'Create a new file, overwrite project units?', - message: `This will add the sample as a new file to your project, and replace your current project units with the sample's units.`, - }) - : CommandBarOverwriteWarning({}), + CommandBarOverwriteWarning({ + heading: + 'method' in argumentsToSubmit && + argumentsToSubmit.method === 'newFile' + ? 'Create a new file from sample?' + : 'Overwrite current file with sample?', + message: + 'method' in argumentsToSubmit && + argumentsToSubmit.method === 'newFile' + ? 'This will create a new file in the current project and open it.' + : 'This will erase your current file and load the sample part.', + }), groupId: 'code', onSubmit(data) { if (!data?.sample) { diff --git a/src/lib/settings/initialSettings.tsx b/src/lib/settings/initialSettings.tsx index f266612f3..21bccdb79 100644 --- a/src/lib/settings/initialSettings.tsx +++ b/src/lib/settings/initialSettings.tsx @@ -22,6 +22,7 @@ import { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionTyp import { OnboardingStatus } from '@rust/kcl-lib/bindings/OnboardingStatus' import { NamedView } from '@rust/kcl-lib/bindings/NamedView' import { CameraOrbitType } from '@rust/kcl-lib/bindings/CameraOrbitType' +import { DEFAULT_DEFAULT_LENGTH_UNIT } from 'lib/constants' /** * A setting that can be set at the user or project level @@ -300,8 +301,9 @@ export function createSettings() { * The default unit to use in modeling dimensions */ defaultUnit: new Setting({ - defaultValue: 'mm', - description: 'The default unit to use in modeling dimensions', + defaultValue: DEFAULT_DEFAULT_LENGTH_UNIT, + description: + 'Set the default length unit setting value to give any new files.', validate: (v) => baseUnitsUnion.includes(v), commandConfig: { inputType: 'options', diff --git a/src/lib/settings/settingsTypes.ts b/src/lib/settings/settingsTypes.ts index 5dc4c1eca..bbf17ec4a 100644 --- a/src/lib/settings/settingsTypes.ts +++ b/src/lib/settings/settingsTypes.ts @@ -145,7 +145,7 @@ export type SaveSettingsPayload = RecursiveSettingsPayloads /** * Annotation names for default units are defined on rust side in - * src/wasm-lib/kcl/src/execution/annotations.rs + * rust/kcl-lib/src/execution/annotations.rs */ export interface KclSettingsAnnotation { defaultLengthUnit?: UnitLength_type diff --git a/src/lib/wasm_lib_wrapper.ts b/src/lib/wasm_lib_wrapper.ts index 6b972e01b..8dbddd847 100644 --- a/src/lib/wasm_lib_wrapper.ts +++ b/src/lib/wasm_lib_wrapper.ts @@ -22,6 +22,7 @@ import { base64_decode as Base64Decode, kcl_settings as KclSettings, change_kcl_settings as ChangeKclSettings, + is_kcl_empty_or_only_settings as IsKclEmptyOrOnlySettings, get_kcl_version as GetKclVersion, serialize_configuration as SerializeConfiguration, serialize_project_configuration as SerializeProjectConfiguration, @@ -93,6 +94,11 @@ export const kcl_settings: typeof KclSettings = (...args) => { export const change_kcl_settings: typeof ChangeKclSettings = (...args) => { return getModule().change_kcl_settings(...args) } +export const is_kcl_empty_or_only_settings: typeof IsKclEmptyOrOnlySettings = ( + ...args +) => { + return getModule().is_kcl_empty_or_only_settings(...args) +} export const get_kcl_version: typeof GetKclVersion = () => { return getModule().get_kcl_version() } diff --git a/src/machines/fileMachine.ts b/src/machines/fileMachine.ts index e067d85dc..f628ed643 100644 --- a/src/machines/fileMachine.ts +++ b/src/machines/fileMachine.ts @@ -126,7 +126,7 @@ export const fileMachine = setup({ makeDir: boolean selectedDirectory: FileEntry targetPathToClone?: string - content: string + content?: string shouldSetToRename: boolean } }) => Promise.resolve({ message: '', path: '' }) @@ -152,7 +152,7 @@ export const fileMachine = setup({ name: string makeDir: boolean selectedDirectory: FileEntry - content: string + content?: string } }) => Promise.resolve({ path: '' }) ), @@ -238,7 +238,7 @@ export const fileMachine = setup({ makeDir: event.data.makeDir, selectedDirectory: context.selectedDirectory, targetPathToClone: event.data.targetPathToClone, - content: event.data.content ?? '', + content: event.data.content, shouldSetToRename: event.data.shouldSetToRename ?? false, } }, @@ -417,7 +417,7 @@ export const fileMachine = setup({ name: event.data.name, makeDir: event.data.makeDir, selectedDirectory: context.selectedDirectory, - content: event.data.content ?? '', + content: event.data.content, } }, onDone: 'Reading files', diff --git a/src/routes/Onboarding/Introduction.tsx b/src/routes/Onboarding/Introduction.tsx index b4a9e052e..c3103d12c 100644 --- a/src/routes/Onboarding/Introduction.tsx +++ b/src/routes/Onboarding/Introduction.tsx @@ -14,6 +14,7 @@ import { useFileContext } from 'hooks/useFileContext' import { useLspContext } from 'components/LspProvider' import { reportRejection } from 'lib/trap' import { useSettings } from 'machines/appMachine' +import { isKclEmptyOrOnlySettings } from 'lang/wasm' /** * Show either a welcome screen or a warning screen @@ -21,7 +22,7 @@ import { useSettings } from 'machines/appMachine' */ export default function OnboardingIntroduction() { const [shouldShowWarning, setShouldShowWarning] = useState( - codeManager.code !== '' && codeManager.code !== bracket + !isKclEmptyOrOnlySettings(codeManager.code) && codeManager.code !== bracket ) return shouldShowWarning ? (