Skip to content

Commit f1cda8a

Browse files
committed
fix(explorer): support terminal.external.explorer
1 parent 2af4fd3 commit f1cda8a

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

addons/explorer/src/renderer/FileExplorer.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { nextTick, watch, watchEffect } from 'vue'
66
import { FileEntity } from '../types/file'
77
88
const { VisualIcon } = commas.ui.vueAssets
9+
const settings = commas.remote.useSettings()
910
1011
let modelValue = $(defineModel<string>({ default: '' }))
1112
@@ -93,7 +94,20 @@ function openExternal(file: FileEntity) {
9394
}
9495
}
9596
96-
function openExternalDirectory() {
97+
const externalExplorer = $computed(() => {
98+
return settings['terminal.external.explorer']
99+
})
100+
101+
function openExternalExplorer() {
102+
if (!openExternalExplorer) {
103+
return openDirectory()
104+
}
105+
const explorer = externalExplorer
106+
.replace(/\$\{directory\}/g, modelValue)
107+
return ipcRenderer.invoke('execute', explorer)
108+
}
109+
110+
function openDirectory() {
97111
ipcRenderer.invoke('open-path', modelValue)
98112
}
99113
@@ -185,9 +199,12 @@ function autoselect(event: FocusEvent) {
185199
<span class="link form-action" @click="openNewTab">
186200
<VisualIcon name="lucide-terminal" />
187201
</span>
188-
<span class="link form-action" @click="openExternalDirectory">
202+
<span v-if="externalExplorer" class="link form-action" @click="openExternalExplorer">
189203
<VisualIcon name="lucide-square-arrow-out-up-right" />
190204
</span>
205+
<span class="link form-action" @click="openDirectory">
206+
<VisualIcon :name="externalExplorer ? 'lucide-folder-open' : 'lucide-square-arrow-out-up-right'" />
207+
</span>
191208
</div>
192209
<div class="file-list">
193210
<a

addons/launcher/src/renderer/launcher.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ipcRenderer } from '@commas/electron-ipc'
22
import type { TerminalContext, TerminalInfo, TerminalTab, TerminalTabCharacter } from '@commas/types/terminal'
33
import * as commas from 'commas:api/renderer'
4-
import { shell } from 'electron'
54
import type { Launcher } from '../types/launcher'
65
import { getLauncherCommand } from './utils'
76

@@ -136,7 +135,7 @@ export async function startLauncherExternally(launcher: Launcher) {
136135
)
137136
if (!explorer) {
138137
if (launcher.remote) return
139-
return shell.openPath(directory)
138+
return commas.remote.openDirectory(directory)
140139
}
141140
explorer = explorer
142141
.replace(/\$\{directory\}/g, directory)

src/renderer/compositions/shell.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ export async function confirmClosing() {
6363
}
6464

6565
export function openFile(file: string) {
66-
globalHandler.invoke('global-renderer:open-file', file)
66+
return globalHandler.invoke('global-renderer:open-file', file)
6767
}
6868

6969
export function openDirectory(directory: string) {
70-
globalHandler.invoke('global-renderer:open-directory', directory)
70+
return globalHandler.invoke('global-renderer:open-directory', directory)
7171
}
7272

7373
export function showDirectory(file: string) {
74-
globalHandler.invoke('global-renderer:show-directory', file)
74+
return globalHandler.invoke('global-renderer:show-directory', file)
7575
}
7676

7777
export function openURL(url: string) {
78-
globalHandler.invoke('global-renderer:open-url', url)
78+
return globalHandler.invoke('global-renderer:open-url', url)
7979
}
8080

8181
export function handleShellMessages() {

0 commit comments

Comments
 (0)