clean up
This commit is contained in:
@ -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({
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
})
|
||||
|
Reference in New Issue
Block a user