Update lower-right corner units menu to read and edit inline settings annotations if present (#5212)
* WIP show annotation length unit setting in LowerRightControls if present * Add logic for changing settings annotation if it's present * Add E2E test * Cleanup lints, fmt, tsc, logs * Change to use settings from Rust helper function - Fix thrown error to use the cause field - Fix function names to not use "get" * Remove unneeded constants * Post-merge fixups * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Add back `ImportStatement` to make tsc happy (thanks @jtran!) * fmt --------- Co-authored-by: Jonathan Tran <jonnytran@gmail.com> Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -25,7 +25,7 @@ import {
|
||||
SourceRange,
|
||||
topLevelRange,
|
||||
} from 'lang/wasm'
|
||||
import { getNodeFromPath } from './queryAst'
|
||||
import { getNodeFromPath, getSettingsAnnotation } from './queryAst'
|
||||
import { codeManager, editorManager, sceneInfra } from 'lib/singletons'
|
||||
import { Diagnostic } from '@codemirror/lint'
|
||||
import { markOnce } from 'lib/performance'
|
||||
@ -35,6 +35,7 @@ import {
|
||||
ModelingCmdReq_type,
|
||||
} from '@kittycad/lib/dist/types/src/models'
|
||||
import { Operation } from 'wasm-lib/kcl/bindings/Operation'
|
||||
import { KclSettingsAnnotation } from 'lib/settings/settingsTypes'
|
||||
|
||||
interface ExecuteArgs {
|
||||
ast?: Node<Program>
|
||||
@ -70,6 +71,7 @@ export class KclManager {
|
||||
private _wasmInitFailed = true
|
||||
private _hasErrors = false
|
||||
private _switchedFiles = false
|
||||
private _fileSettings: KclSettingsAnnotation = {}
|
||||
|
||||
engineCommandManager: EngineCommandManager
|
||||
|
||||
@ -368,6 +370,13 @@ export class KclManager {
|
||||
await this.disableSketchMode()
|
||||
}
|
||||
|
||||
let fileSettings = getSettingsAnnotation(ast)
|
||||
if (err(fileSettings)) {
|
||||
console.error(fileSettings)
|
||||
fileSettings = {}
|
||||
}
|
||||
this.fileSettings = fileSettings
|
||||
|
||||
this.logs = logs
|
||||
this.errors = errors
|
||||
// Do not add the errors since the program was interrupted and the error is not a real KCL error
|
||||
@ -699,6 +708,14 @@ export class KclManager {
|
||||
_isAstEmpty(ast: Node<Program>) {
|
||||
return ast.start === 0 && ast.end === 0 && ast.body.length === 0
|
||||
}
|
||||
|
||||
get fileSettings() {
|
||||
return this._fileSettings
|
||||
}
|
||||
|
||||
set fileSettings(settings: KclSettingsAnnotation) {
|
||||
this._fileSettings = settings
|
||||
}
|
||||
}
|
||||
|
||||
const defaultSelectionFilter: EntityType_type[] = [
|
||||
|
Reference in New Issue
Block a user