clean up
This commit is contained in:
@ -329,7 +329,7 @@ export const FileMachineProvider = ({
|
|||||||
onSubmit: async (data) => {
|
onSubmit: async (data) => {
|
||||||
if (data.method === 'overwrite') {
|
if (data.method === 'overwrite') {
|
||||||
codeManager.updateCodeStateEditor(data.code)
|
codeManager.updateCodeStateEditor(data.code)
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
await codeManager.writeToFile()
|
await codeManager.writeToFile()
|
||||||
} else if (data.method === 'newFile' && isDesktop()) {
|
} else if (data.method === 'newFile' && isDesktop()) {
|
||||||
send({
|
send({
|
||||||
|
@ -22,6 +22,7 @@ import usePlatform from 'hooks/usePlatform'
|
|||||||
import { FileEntry } from 'lib/project'
|
import { FileEntry } from 'lib/project'
|
||||||
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
|
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
|
||||||
import { reportRejection } from 'lib/trap'
|
import { reportRejection } from 'lib/trap'
|
||||||
|
import { normalizeLineEndings } from 'lib/codeEditor'
|
||||||
|
|
||||||
function getIndentationCSS(level: number) {
|
function getIndentationCSS(level: number) {
|
||||||
return `calc(1rem * ${level + 1})`
|
return `calc(1rem * ${level + 1})`
|
||||||
@ -189,25 +190,23 @@ const FileTreeItem = ({
|
|||||||
// Because subtrees only render when they are opened, that means this
|
// Because subtrees only render when they are opened, that means this
|
||||||
// only listens when they open. Because this acts like a useEffect, when
|
// only listens when they open. Because this acts like a useEffect, when
|
||||||
// the ReactNodes are destroyed, so is this listener :)
|
// the ReactNodes are destroyed, so is this listener :)
|
||||||
/** Disabling this in favor of faster file writes until we fix file writing **/
|
useFileSystemWatcher(
|
||||||
/* useFileSystemWatcher(
|
async (eventType, path) => {
|
||||||
* async (eventType, path) => {
|
// Prevents a cyclic read / write causing editor problems such as
|
||||||
* // Prevents a cyclic read / write causing editor problems such as
|
// misplaced cursor positions.
|
||||||
* // misplaced cursor positions.
|
if (codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher) {
|
||||||
* if (codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher) {
|
codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = false
|
||||||
* codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = false
|
return
|
||||||
* return
|
}
|
||||||
* }
|
if (isCurrentFile && eventType === 'change') {
|
||||||
|
let code = await window.electron.readFile(path, { encoding: 'utf-8' })
|
||||||
* if (isCurrentFile && eventType === 'change') {
|
code = normalizeLineEndings(code)
|
||||||
* let code = await window.electron.readFile(path, { encoding: 'utf-8' })
|
codeManager.updateCodeStateEditor(code)
|
||||||
* code = normalizeLineEndings(code)
|
}
|
||||||
* codeManager.updateCodeStateEditor(code)
|
fileSend({ type: 'Refresh' })
|
||||||
* }
|
},
|
||||||
* fileSend({ type: 'Refresh' })
|
[fileOrDir.path]
|
||||||
* },
|
)
|
||||||
* [fileOrDir.path]
|
|
||||||
* ) */
|
|
||||||
|
|
||||||
const showNewTreeEntry =
|
const showNewTreeEntry =
|
||||||
newTreeEntry !== undefined &&
|
newTreeEntry !== undefined &&
|
||||||
@ -263,7 +262,7 @@ const FileTreeItem = ({
|
|||||||
await codeManager.writeToFile()
|
await codeManager.writeToFile()
|
||||||
|
|
||||||
// Prevent seeing the model built one piece at a time when changing files
|
// Prevent seeing the model built one piece at a time when changing files
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
} else {
|
} else {
|
||||||
// Let the lsp servers know we closed a file.
|
// Let the lsp servers know we closed a file.
|
||||||
onFileClose(currentFile?.path || null, project?.path || null)
|
onFileClose(currentFile?.path || null, project?.path || null)
|
||||||
|
@ -124,7 +124,7 @@ const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => {
|
|||||||
clearImportSearchParams()
|
clearImportSearchParams()
|
||||||
codeManager.updateCodeStateEditor(input.code || '')
|
codeManager.updateCodeStateEditor(input.code || '')
|
||||||
await codeManager.writeToFile()
|
await codeManager.writeToFile()
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: 'File overwritten successfully',
|
message: 'File overwritten successfully',
|
||||||
|
@ -187,7 +187,7 @@ export const SettingsAuthProviderBase = ({
|
|||||||
) {
|
) {
|
||||||
// Unit changes requires a re-exec of code
|
// Unit changes requires a re-exec of code
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
kclManager.executeCode({ zoomToFit: true })
|
kclManager.executeCode(true)
|
||||||
} else {
|
} else {
|
||||||
// For any future logging we'd like to do
|
// For any future logging we'd like to do
|
||||||
// console.log(
|
// console.log(
|
||||||
|
@ -60,7 +60,7 @@ export const Stream = () => {
|
|||||||
*/
|
*/
|
||||||
function executeCodeAndPlayStream() {
|
function executeCodeAndPlayStream() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
kclManager.executeCode({ zoomToFit: true }).then(async () => {
|
kclManager.executeCode(true).then(async () => {
|
||||||
await videoRef.current?.play().catch((e) => {
|
await videoRef.current?.play().catch((e) => {
|
||||||
console.warn('Video playing was prevented', e, videoRef.current)
|
console.warn('Video playing was prevented', e, videoRef.current)
|
||||||
})
|
})
|
||||||
|
@ -457,7 +457,7 @@ export class KclManager {
|
|||||||
this._cancelTokens.set(key, true)
|
this._cancelTokens.set(key, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async executeCode(opts?: { zoomToFit?: true }): Promise<void> {
|
async executeCode(zoomToFit?: boolean): Promise<void> {
|
||||||
const ast = await this.safeParse(codeManager.code)
|
const ast = await this.safeParse(codeManager.code)
|
||||||
|
|
||||||
if (!ast) {
|
if (!ast) {
|
||||||
@ -465,10 +465,10 @@ export class KclManager {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// zoomToFit = this.tryToZoomToFitOnCodeUpdate(ast, opts?.zoomToFit)
|
zoomToFit = this.tryToZoomToFitOnCodeUpdate(ast, zoomToFit)
|
||||||
|
|
||||||
this.ast = { ...ast }
|
this.ast = { ...ast }
|
||||||
return this.executeAst(opts)
|
return this.executeAst({ zoomToFit })
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This will override the zoom to fit to zoom into the model if the previous AST was empty.
|
* This will override the zoom to fit to zoom into the model if the previous AST was empty.
|
||||||
|
@ -157,7 +157,7 @@ export default class CodeManager {
|
|||||||
toast.error('Error saving file, please check file permissions')
|
toast.error('Error saving file, please check file permissions')
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
}, 10)
|
}, 1000)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
safeLSSetItem(PERSIST_CODE_KEY, this.code)
|
safeLSSetItem(PERSIST_CODE_KEY, this.code)
|
||||||
|
@ -50,7 +50,7 @@ process.chdir(DIR_KCL_SAMPLES)
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await initPromise
|
await initPromise
|
||||||
}, 5_000)
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
try {
|
try {
|
||||||
@ -78,6 +78,6 @@ describe('Test KCL Samples from public Github repository', () => {
|
|||||||
},
|
},
|
||||||
files.length * 1000
|
files.length * 1000
|
||||||
)
|
)
|
||||||
}, 3_0000)
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -368,14 +368,12 @@ export type ModelingMachineEvent =
|
|||||||
tool: SketchTool
|
tool: SketchTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// | { type: 'Finish rectangle' | 'Finish center rectangle' | 'Finish circle three point' | 'Finish circle' }
|
|
||||||
| { type: 'Finish rectangle' }
|
| { type: 'Finish rectangle' }
|
||||||
| { type: 'Finish center rectangle' }
|
| { type: 'Finish center rectangle' }
|
||||||
| { type: 'Finish circle' }
|
| { type: 'Finish circle' }
|
||||||
| { type: 'Finish circle three point' }
|
| { type: 'Finish circle three point' }
|
||||||
| { type: 'Artifact graph populated' }
|
| { type: 'Artifact graph populated' }
|
||||||
| { type: 'Artifact graph emptied' }
|
| { type: 'Artifact graph emptied' }
|
||||||
// | { type: 'xstate.done.actor.actor-circle-three-point' }
|
|
||||||
|
|
||||||
export type MoveDesc = { line: number; snippet: string }
|
export type MoveDesc = { line: number; snippet: string }
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ function OnboardingWarningWeb(props: OnboardingResetWarningProps) {
|
|||||||
codeManager.updateCodeStateEditor(bracket)
|
codeManager.updateCodeStateEditor(bracket)
|
||||||
await codeManager.writeToFile()
|
await codeManager.writeToFile()
|
||||||
|
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
props.setShouldShowWarning(false)
|
props.setShouldShowWarning(false)
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -8,7 +8,7 @@ export default function Sketching() {
|
|||||||
async function clearEditor() {
|
async function clearEditor() {
|
||||||
// We do want to update both the state and editor here.
|
// We do want to update both the state and editor here.
|
||||||
codeManager.updateCodeStateEditor('')
|
codeManager.updateCodeStateEditor('')
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
|
@ -103,7 +103,7 @@ export function useDemoCode() {
|
|||||||
setTimeout(
|
setTimeout(
|
||||||
toSync(async () => {
|
toSync(async () => {
|
||||||
codeManager.updateCodeStateEditor(bracket)
|
codeManager.updateCodeStateEditor(bracket)
|
||||||
await kclManager.executeCode({ zoomToFit: true })
|
await kclManager.executeCode(true)
|
||||||
await codeManager.writeToFile()
|
await codeManager.writeToFile()
|
||||||
}, reportRejection)
|
}, reportRejection)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user