Skip to content

Commit

Permalink
A snapshot a day keeps the bugs away! πŸ“·πŸ› (OS: ubuntu)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 15, 2024
1 parent 5420388 commit 0d030ae
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/components/ModelingSidebar/ModelingPanes/MemoryPane.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import toast from 'react-hot-toast'
import ReactJson from 'react-json-view'
import { useMemo } from 'react'
import { ProgramMemory, Path, ExtrudeSurface, sketchGroupFromKclValue } from 'lang/wasm'
import {
ProgramMemory,
Path,
ExtrudeSurface,
sketchGroupFromKclValue,
} from 'lang/wasm'
import { useKclContext } from 'lang/KclProvider'
import { useResolvedTheme } from 'hooks/useResolvedTheme'
import { ActionButton } from 'components/ActionButton'
Expand Down
12 changes: 10 additions & 2 deletions src/lang/executor.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import fs from 'node:fs'

import { parse, ProgramMemory, SketchGroup, initPromise, sketchGroupFromKclValue } from './wasm'
import {
parse,
ProgramMemory,
SketchGroup,
initPromise,
sketchGroupFromKclValue,
} from './wasm'
import { enginelessExecutor } from '../lib/testHelpers'
import { KCLError } from './errors'

Expand Down Expand Up @@ -385,7 +391,9 @@ describe('testing math operators', () => {
`legLen(segLen(seg01), myVar)`
)
const removedUnaryExpMem = await exe(removedUnaryExp)
const removedUnaryExpMemSketch = sketchGroupFromKclValue(removedUnaryExpMem.get('part001'))
const removedUnaryExpMemSketch = sketchGroupFromKclValue(
removedUnaryExpMem.get('part001')
)

// without the minus sign, the y value should be 8
expect((removedUnaryExpMemSketch as SketchGroup).value?.[1]?.to).toEqual([
Expand Down
4 changes: 3 additions & 1 deletion src/lang/modifyAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,9 @@ export async function deleteFromSelection(
if (err(parent)) {
return
}
const sketchToPreserve = sketchGroupFromKclValue(programMemory.get(sketchName))
const sketchToPreserve = sketchGroupFromKclValue(
programMemory.get(sketchName)
)
if (!sketchToPreserve) {
return new Error(`${sketchName} is not a sketchgroup`)
}
Expand Down
11 changes: 6 additions & 5 deletions src/lang/queryAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export function isLinesParallelAndConstrained(
if (err(_varDec)) return _varDec
const varDec = _varDec.node
const varName = (varDec as VariableDeclaration)?.declarations[0]?.id?.name
const sg= sketchGroupFromKclValue(programMemory?.get(varName))
const sg = sketchGroupFromKclValue(programMemory?.get(varName))
if (!sg) {
return new Error(`${varName} is not a sketchgroup`)
}
Expand Down Expand Up @@ -712,9 +712,7 @@ export function isLinesParallelAndConstrained(
constraintType === 'angle' || constraintLevel === 'full'

// get the previous segment
const prevSegment = sg.value[
secondaryIndex - 1
]
const prevSegment = sg.value[secondaryIndex - 1]
const prevSourceRange = prevSegment.__geoMeta.sourceRange

const isParallelAndConstrained =
Expand Down Expand Up @@ -783,7 +781,10 @@ export function hasExtrudeSketchGroup({
if (varDec.type !== 'VariableDeclaration') return false
const varName = varDec.declarations[0].id.name
const varValue = programMemory?.get(varName)
return varValue?.type === 'ExtrudeGroup'|| sketchGroupFromKclValue(varValue)!== null
return (
varValue?.type === 'ExtrudeGroup' ||
sketchGroupFromKclValue(varValue) !== null
)
}

export function isSingleCursorInPipe(
Expand Down
12 changes: 9 additions & 3 deletions src/lang/std/sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,9 @@ export const angledLineOfXLength: SketchLineHelper = {
const { node: varDec } = nodeMeta2

const variableName = varDec.id.name
const sketch = sketchGroupFromKclValue(previousProgramMemory?.get(variableName))
const sketch = sketchGroupFromKclValue(
previousProgramMemory?.get(variableName)
)
if (!sketch) {
return new Error('not a SketchGroup')
}
Expand Down Expand Up @@ -1106,7 +1108,9 @@ export const angledLineOfYLength: SketchLineHelper = {
if (err(nodeMeta2)) return nodeMeta2
const { node: varDec } = nodeMeta2
const variableName = varDec.id.name
const sketch = sketchGroupFromKclValue(previousProgramMemory?.get(variableName))
const sketch = sketchGroupFromKclValue(
previousProgramMemory?.get(variableName)
)
if (!sketch) {
return new Error('not a SketchGroup')
}
Expand Down Expand Up @@ -1444,7 +1448,9 @@ export const angledLineThatIntersects: SketchLineHelper = {

const { node: varDec } = nodeMeta2
const varName = varDec.declarations[0].id.name
const sketchGroup = sketchGroupFromKclValue(previousProgramMemory.get(varName))
const sketchGroup = sketchGroupFromKclValue(
previousProgramMemory.get(varName)
)
if (!sketchGroup) {
return new Error('Not a sketchgroup')
}
Expand Down

0 comments on commit 0d030ae

Please sign in to comment.