dont bust cache on external file change (#6756)
* dont bust cache on external file change Signed-off-by: Jess Frazelle <github@jessfraz.com> * dont bust cache on external file change Signed-off-by: Jess Frazelle <github@jessfraz.com> * dont bust cache on external file change Signed-off-by: Jess Frazelle <github@jessfraz.com> * add to the comment Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -24,7 +24,7 @@ import { sortFilesAndDirectories } from '@src/lib/desktopFS'
|
||||
import useHotkeyWrapper from '@src/lib/hotkeyWrapper'
|
||||
import { PATHS } from '@src/lib/paths'
|
||||
import type { FileEntry } from '@src/lib/project'
|
||||
import { codeManager, kclManager, rustContext } from '@src/lib/singletons'
|
||||
import { codeManager, kclManager } from '@src/lib/singletons'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import type { IndexLoaderData } from '@src/lib/types'
|
||||
|
||||
@ -32,7 +32,6 @@ import { ToastInsert } from '@src/components/ToastInsert'
|
||||
import { commandBarActor } from '@src/lib/singletons'
|
||||
import toast from 'react-hot-toast'
|
||||
import styles from './FileTree.module.css'
|
||||
import { jsAppSettings } from '@src/lib/settings/settingsUtils'
|
||||
|
||||
function getIndentationCSS(level: number) {
|
||||
return `calc(1rem * ${level + 1})`
|
||||
@ -229,10 +228,6 @@ const FileTreeItem = ({
|
||||
code = normalizeLineEndings(code)
|
||||
codeManager.updateCodeStateEditor(code)
|
||||
} else if (isImportedInCurrentFile && eventType === 'change') {
|
||||
await rustContext.clearSceneAndBustCache(
|
||||
await jsAppSettings(),
|
||||
codeManager?.currentFilePath || undefined
|
||||
)
|
||||
await kclManager.executeAst()
|
||||
}
|
||||
fileSend({ type: 'Refresh' })
|
||||
|
@ -1,6 +1,5 @@
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
import { BSON } from 'bson'
|
||||
import type { Configuration } from '@rust/kcl-lib/bindings/Configuration'
|
||||
import type { DefaultPlanes } from '@rust/kcl-lib/bindings/DefaultPlanes'
|
||||
import type { KclError as RustKclError } from '@rust/kcl-lib/bindings/KclError'
|
||||
@ -8,7 +7,9 @@ import type { OutputFormat3d } from '@rust/kcl-lib/bindings/ModelingCmd'
|
||||
import type { Node } from '@rust/kcl-lib/bindings/Node'
|
||||
import type { Program } from '@rust/kcl-lib/bindings/Program'
|
||||
import type { Context } from '@rust/kcl-wasm-lib/pkg/kcl_wasm_lib'
|
||||
import { BSON } from 'bson'
|
||||
|
||||
import type { Models } from '@kittycad/lib/dist/types/src'
|
||||
import type { EngineCommandManager } from '@src/lang/std/engineConnection'
|
||||
import { fileSystemManager } from '@src/lang/std/fileSystemManager'
|
||||
import type { ExecState } from '@src/lang/wasm'
|
||||
@ -25,7 +26,6 @@ import { err, reportRejection } from '@src/lib/trap'
|
||||
import type { DeepPartial } from '@src/lib/types'
|
||||
import type { ModuleType } from '@src/lib/wasm_lib_wrapper'
|
||||
import { getModule } from '@src/lib/wasm_lib_wrapper'
|
||||
import type { Models } from '@kittycad/lib/dist/types/src'
|
||||
|
||||
export default class RustContext {
|
||||
private wasmInitFailed: boolean = true
|
||||
@ -155,6 +155,19 @@ export default class RustContext {
|
||||
}
|
||||
|
||||
// Clear/reset the scene and bust the cache.
|
||||
// Do not use this function unless you absolutely need to. In most cases,
|
||||
// we should just fix the cache for whatever bug you are seeing.
|
||||
// The only time it makes sense to run this is if the engine disconnects and
|
||||
// reconnects. The rust side has no idea that happened and will think the
|
||||
// cache is still valid.
|
||||
// Caching on the rust side accounts for changes to files outside of the
|
||||
// scope of the current file the user is on. It collects all the dependencies
|
||||
// and checks if any of them have changed. If they have, it will bust the
|
||||
// cache and recompile the scene.
|
||||
// The typescript side should never raw dog clear the scene since that would
|
||||
// fuck with the cache as well. So if you _really_ want to just clear the scene
|
||||
// AND NOT re-execute, you can use this for that. But in 99.999999% of cases just
|
||||
// re-execute.
|
||||
async clearSceneAndBustCache(
|
||||
settings: DeepPartial<Configuration>,
|
||||
path?: string
|
||||
|
Reference in New Issue
Block a user