This commit is contained in:
Kurt Hutten Irev-Dev
2025-02-10 22:23:34 +11:00
parent 1d8348c2cf
commit b213834316
12 changed files with 32 additions and 35 deletions

View File

@ -329,7 +329,7 @@ export const FileMachineProvider = ({
onSubmit: async (data) => {
if (data.method === 'overwrite') {
codeManager.updateCodeStateEditor(data.code)
await kclManager.executeCode({ zoomToFit: true })
await kclManager.executeCode(true)
await codeManager.writeToFile()
} else if (data.method === 'newFile' && isDesktop()) {
send({

View File

@ -22,6 +22,7 @@ import usePlatform from 'hooks/usePlatform'
import { FileEntry } from 'lib/project'
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
import { reportRejection } from 'lib/trap'
import { normalizeLineEndings } from 'lib/codeEditor'
function getIndentationCSS(level: number) {
return `calc(1rem * ${level + 1})`
@ -189,25 +190,23 @@ const FileTreeItem = ({
// Because subtrees only render when they are opened, that means this
// only listens when they open. Because this acts like a useEffect, when
// the ReactNodes are destroyed, so is this listener :)
/** Disabling this in favor of faster file writes until we fix file writing **/
/* useFileSystemWatcher(
* async (eventType, path) => {
* // Prevents a cyclic read / write causing editor problems such as
* // misplaced cursor positions.
* if (codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher) {
* codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = false
* return
* }
* if (isCurrentFile && eventType === 'change') {
* let code = await window.electron.readFile(path, { encoding: 'utf-8' })
* code = normalizeLineEndings(code)
* codeManager.updateCodeStateEditor(code)
* }
* fileSend({ type: 'Refresh' })
* },
* [fileOrDir.path]
* ) */
useFileSystemWatcher(
async (eventType, path) => {
// Prevents a cyclic read / write causing editor problems such as
// misplaced cursor positions.
if (codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher) {
codeManager.writeCausedByAppCheckedInFileTreeFileSystemWatcher = false
return
}
if (isCurrentFile && eventType === 'change') {
let code = await window.electron.readFile(path, { encoding: 'utf-8' })
code = normalizeLineEndings(code)
codeManager.updateCodeStateEditor(code)
}
fileSend({ type: 'Refresh' })
},
[fileOrDir.path]
)
const showNewTreeEntry =
newTreeEntry !== undefined &&
@ -263,7 +262,7 @@ const FileTreeItem = ({
await codeManager.writeToFile()
// Prevent seeing the model built one piece at a time when changing files
await kclManager.executeCode({ zoomToFit: true })
await kclManager.executeCode(true)
} else {
// Let the lsp servers know we closed a file.
onFileClose(currentFile?.path || null, project?.path || null)

View File

@ -124,7 +124,7 @@ const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => {
clearImportSearchParams()
codeManager.updateCodeStateEditor(input.code || '')
await codeManager.writeToFile()
await kclManager.executeCode({ zoomToFit: true })
await kclManager.executeCode(true)
return {
message: 'File overwritten successfully',

View File

@ -187,7 +187,7 @@ export const SettingsAuthProviderBase = ({
) {
// Unit changes requires a re-exec of code
// eslint-disable-next-line @typescript-eslint/no-floating-promises
kclManager.executeCode({ zoomToFit: true })
kclManager.executeCode(true)
} else {
// For any future logging we'd like to do
// console.log(

View File

@ -60,7 +60,7 @@ export const Stream = () => {
*/
function executeCodeAndPlayStream() {
// 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) => {
console.warn('Video playing was prevented', e, videoRef.current)
})