zoom to fit on between projects tauri fix (#2504)
* fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * triiger * make better Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -176,7 +176,11 @@ export class KclManager {
|
||||
// This NEVER updates the code, if you want to update the code DO NOT add to
|
||||
// this function, too many other things that don't want it exist.
|
||||
// just call to codeManager from wherever you want in other files.
|
||||
async executeAst(ast: Program = this._ast, executionId?: number) {
|
||||
async executeAst(
|
||||
ast: Program = this._ast,
|
||||
zoomToFit?: boolean,
|
||||
executionId?: number
|
||||
): Promise<void> {
|
||||
await this?.engineCommandManager?.waitForReady
|
||||
const currentExecutionId = executionId || Date.now()
|
||||
this._cancelTokens.set(currentExecutionId, false)
|
||||
@ -189,6 +193,19 @@ export class KclManager {
|
||||
})
|
||||
sceneInfra.modelingSend({ type: 'code edit during sketch' })
|
||||
defaultSelectionFilter(programMemory, this.engineCommandManager)
|
||||
|
||||
if (zoomToFit) {
|
||||
await this.engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
cmd: {
|
||||
type: 'zoom_to_fit',
|
||||
object_ids: [], // leave empty to zoom to all objects
|
||||
padding: 0.1, // padding around the objects
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
this.isExecuting = false
|
||||
// Check the cancellation token for this execution before applying side effects
|
||||
if (this._cancelTokens.get(currentExecutionId)) {
|
||||
@ -259,14 +276,14 @@ export class KclManager {
|
||||
this._cancelTokens.set(key, true)
|
||||
})
|
||||
}
|
||||
executeCode(force?: boolean) {
|
||||
async executeCode(force?: boolean, zoomToFit?: boolean): Promise<void> {
|
||||
// If we want to force it we don't want to defer it.
|
||||
if (!force) return this._defferer(codeManager.code)
|
||||
|
||||
const ast = this.safeParse(codeManager.code)
|
||||
if (!ast) return
|
||||
this.ast = { ...ast }
|
||||
return this.executeAst(ast)
|
||||
return this.executeAst(ast, zoomToFit)
|
||||
}
|
||||
format() {
|
||||
const originalCode = codeManager.code
|
||||
|
Reference in New Issue
Block a user