Skip to content

Commit

Permalink
Fix for adding node in collapsed functions (#9060)
Browse files Browse the repository at this point in the history
Fixes #9049

There were still some stubs left in node creation code.

# Important Notes
I haven't added any tests, as unit testing the graph store is very difficult - it has much tangled logic there. I'm going to try to untangle it a bit, but in a separate PR.
  • Loading branch information
farmaazon authored Feb 19, 2024
1 parent 2e06b4b commit fddfa11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/gui2/src/components/GraphEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ projectStore.lsRpcConnection.then(
})
},
(err) => {
toast.error(`Connection to language server failed: ${err}`)
toast.error(`Connection to language server failed: ${JSON.stringify(err)}`)
},
)
projectStore.executionContext.on('executionFailed', (err) => {
toast.error(`Execution Failed: ${err}`, {})
toast.error(`Execution Failed: ${JSON.stringify(err)}`, {})
})
onMounted(() => {
Expand Down
7 changes: 2 additions & 5 deletions app/gui2/src/stores/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,12 @@ export const useGraphStore = defineStore('graph', () => {
metadata: NodeMetadataFields = {},
withImports: RequiredImport[] | undefined = undefined,
): Opt<NodeId> {
const mod = proj.module
if (!mod) return
const ident = generateUniqueIdent()
const currentFunc = 'main'
const method = Ast.findModuleMethod(topLevel.value!, currentFunc)
const method = syncModule.value ? methodAstInModule(syncModule.value) : undefined
if (!method) {
console.error(`BUG: Cannot add node: No current function.`)
return
}
const ident = generateUniqueIdent()
metadata.position = { x: position.x, y: position.y }
return edit((edit) => {
if (withImports) addMissingImports(edit, withImports)
Expand Down

0 comments on commit fddfa11

Please sign in to comment.