app: wait for loadFile before opening file tab

This commit is contained in:
Brendan Allan
2026-02-24 16:33:02 +08:00
parent cf5cfb48cd
commit eda71373b0

View File

@@ -24,13 +24,15 @@ export const createOpenReviewFile = (input: {
showAllFiles: () => void showAllFiles: () => void
tabForPath: (path: string) => string tabForPath: (path: string) => string
openTab: (tab: string) => void openTab: (tab: string) => void
loadFile: (path: string) => void loadFile: (path: string) => any | Promise<void>
}) => { }) => {
return (path: string) => { return (path: string) => {
batch(() => { batch(() => {
input.showAllFiles() input.showAllFiles()
input.openTab(input.tabForPath(path)) const maybePromise = input.loadFile(path)
input.loadFile(path) const openTab = () => input.openTab(input.tabForPath(path))
if (maybePromise instanceof Promise) maybePromise.then(openTab)
else openTab()
}) })
} }
} }