Do not write to file or update code editor a ridiculous amount of times and update them both at the most appropriate moments. (#4479)
* Reapply "Deflake project settings override on desktop (#4370)" (#4450)
This reverts commit b11040c23c
.
* Refactor writeToFile and updateCodeEditor to happen at appropriate times
* Turn error into warning about out of date AST.
* Rename setUp to setup
* ONLY reload current file on changes.
* If value is falsey then don't try to executeAst
* Fix up code based selections after constraints
* Correct any last missing code mods
* Update src/clientSideScene/ClientSideSceneComp.tsx
Remove eslint rule no-floating-promises
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* Fixups
* Fix FileTree failing
---------
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
This commit is contained in:
@ -2,13 +2,13 @@ import {
|
||||
SetVarNameModal,
|
||||
createSetVarNameModal,
|
||||
} from 'components/SetVarNameModal'
|
||||
import { editorManager, kclManager } from 'lib/singletons'
|
||||
import { reportRejection, trap } from 'lib/trap'
|
||||
import { editorManager, kclManager, codeManager } from 'lib/singletons'
|
||||
import { reportRejection, trap, err } from 'lib/trap'
|
||||
import { moveValueIntoNewVariable } from 'lang/modifyAst'
|
||||
import { isNodeSafeToReplace } from 'lang/queryAst'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useModelingContext } from './useModelingContext'
|
||||
import { PathToNode, SourceRange } from 'lang/wasm'
|
||||
import { PathToNode, SourceRange, recast } from 'lang/wasm'
|
||||
import { useKclContext } from 'lang/KclProvider'
|
||||
import { toSync } from 'lib/utils'
|
||||
|
||||
@ -57,6 +57,11 @@ export function useConvertToVariable(range?: SourceRange) {
|
||||
)
|
||||
|
||||
await kclManager.updateAst(_modifiedAst, true)
|
||||
|
||||
const newCode = recast(_modifiedAst)
|
||||
if (err(newCode)) return
|
||||
codeManager.updateCodeEditor(newCode)
|
||||
|
||||
return pathToReplacedNode
|
||||
} catch (e) {
|
||||
console.log('error', e)
|
||||
|
Reference in New Issue
Block a user