Skip to content

Commit

Permalink
fix: make createTabPane async
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Nov 21, 2024
1 parent 69ac946 commit 9b02ce1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addons/launcher/src/renderer/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function openLauncher(launcher: Launcher, options: OpenLauncherOpti
const character = getTerminalTabCharacterByLauncher(launcher)
const pane = launcher.pane ? commas.workspace.getPane(launcher.pane) : undefined
if (pane) {
const paneTab = commas.workspace.createPaneTab(pane, {
const paneTab = await commas.workspace.createPaneTab(pane, {
...profile,
command: launcher.command,
character,
Expand Down
10 changes: 5 additions & 5 deletions src/api/modules/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function registerTabPane(this: RendererAPIContext, name: string, pane: TerminalT
if (pane.volatile) {
const generateID = this.$.helper.createIDGenerator()
const factory = pane.factory
pane.factory = info => ({
pane.factory = async info => ({
pid: Number(generateID()),
...factory?.(info),
...await factory?.(info),
})
}
this.$.app.onInvalidate(() => {
Expand All @@ -55,14 +55,14 @@ function getTerminalTabByPane(pane: TerminalTabPane, info: Partial<TerminalTab>

export type PaneTabInfo = Pick<TerminalTab, 'command' | 'process' | 'cwd' | 'shell' | 'character'>

function createPaneTab(pane: TerminalTabPane, info?: Partial<PaneTabInfo>) {
async function createPaneTab(pane: TerminalTabPane, info?: Partial<PaneTabInfo>) {
return reactive({
pid: 0,
process: pane.name,
title: '',
cwd: '',
...info,
...pane.factory?.(info),
...await pane.factory?.(info),
pane: markRaw(pane),
} as TerminalTab)
}
Expand All @@ -77,7 +77,7 @@ async function openPaneTab(name: string, info?: Partial<PaneTabInfo>) {
return tab
}
}
const paneTab = createPaneTab(pane, info)
const paneTab = await createPaneTab(pane, info)
await activateOrAddTerminalTab(paneTab)
return paneTab
}
Expand Down
4 changes: 3 additions & 1 deletion src/types/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export interface TerminalTabPane {
save?: () => void,
},
volatile?: boolean,
factory?: (info?: Partial<TerminalTab>) => Partial<TerminalTab> | undefined,
factory?: (
info?: Partial<TerminalTab>
) => Partial<TerminalTab> | undefined | Promise<Partial<TerminalTab> | undefined>,
}

export interface TerminalTabCharacter {
Expand Down

0 comments on commit 9b02ce1

Please sign in to comment.