mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-19 15:14:49 +00:00
fix(app): load tab on open file
This commit is contained in:
@@ -720,6 +720,7 @@ export default function Page() {
|
|||||||
showAllFiles,
|
showAllFiles,
|
||||||
tabForPath: file.tab,
|
tabForPath: file.tab,
|
||||||
openTab: tabs().open,
|
openTab: tabs().open,
|
||||||
|
setActive: tabs().setActive,
|
||||||
loadFile: file.load,
|
loadFile: file.load,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ describe("createOpenReviewFile", () => {
|
|||||||
return `file://${path}`
|
return `file://${path}`
|
||||||
},
|
},
|
||||||
openTab: (tab) => calls.push(`open:${tab}`),
|
openTab: (tab) => calls.push(`open:${tab}`),
|
||||||
|
setActive: (tab) => calls.push(`active:${tab}`),
|
||||||
loadFile: (path) => calls.push(`load:${path}`),
|
loadFile: (path) => calls.push(`load:${path}`),
|
||||||
})
|
})
|
||||||
|
|
||||||
openReviewFile("src/a.ts")
|
openReviewFile("src/a.ts")
|
||||||
|
|
||||||
expect(calls).toEqual(["show", "load:src/a.ts", "tab:src/a.ts", "open:file://src/a.ts"])
|
expect(calls).toEqual(["show", "load:src/a.ts", "tab:src/a.ts", "open:file://src/a.ts", "active:file://src/a.ts"])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -24,15 +24,20 @@ export const createOpenReviewFile = (input: {
|
|||||||
showAllFiles: () => void
|
showAllFiles: () => void
|
||||||
tabForPath: (path: string) => string
|
tabForPath: (path: string) => string
|
||||||
openTab: (tab: string) => void
|
openTab: (tab: string) => void
|
||||||
|
setActive: (tab: string) => void
|
||||||
loadFile: (path: string) => any | Promise<void>
|
loadFile: (path: string) => any | Promise<void>
|
||||||
}) => {
|
}) => {
|
||||||
return (path: string) => {
|
return (path: string) => {
|
||||||
batch(() => {
|
batch(() => {
|
||||||
input.showAllFiles()
|
input.showAllFiles()
|
||||||
const maybePromise = input.loadFile(path)
|
const maybePromise = input.loadFile(path)
|
||||||
const openTab = () => input.openTab(input.tabForPath(path))
|
const open = () => {
|
||||||
if (maybePromise instanceof Promise) maybePromise.then(openTab)
|
const tab = input.tabForPath(path)
|
||||||
else openTab()
|
input.openTab(tab)
|
||||||
|
input.setActive(tab)
|
||||||
|
}
|
||||||
|
if (maybePromise instanceof Promise) maybePromise.then(open)
|
||||||
|
else open()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user