Skip to content

Commit 3e4fe8c

Browse files
authored
loosen up the requirements to show the File Browser in term context menu (#3232)
1 parent 4969ee1 commit 3e4fe8c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

frontend/app/view/term/term-model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { boundNumber, fireAndForget, stringToBase64 } from "@/util/util";
4040
import * as jotai from "jotai";
4141
import * as React from "react";
4242
import { getBlockingCommand } from "./shellblocking";
43-
import { computeTheme, DefaultTermTheme, trimTerminalSelection } from "./termutil";
43+
import { computeTheme, DefaultTermTheme, isLikelyOnSameHost, trimTerminalSelection } from "./termutil";
4444
import { TermWrap, WebGLSupported } from "./termwrap";
4545

4646
export class TermViewModel implements ViewModel {
@@ -958,9 +958,9 @@ export class TermViewModel implements ViewModel {
958958
});
959959
fullMenu.push({ type: "separator" });
960960

961-
const shellIntegrationStatus = globalStore.get(this.termRef?.current?.shellIntegrationStatusAtom);
961+
const lastCommand = globalStore.get(this.termRef?.current?.lastCommandAtom);
962962
const cwd = blockData?.meta?.["cmd:cwd"];
963-
const canShowFileBrowser = shellIntegrationStatus === "ready" && cwd != null;
963+
const canShowFileBrowser = cwd != null && isLikelyOnSameHost(lastCommand);
964964

965965
if (canShowFileBrowser) {
966966
fullMenu.push({

frontend/app/view/term/termutil.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ export function bufferLinesToText(buffer: TermTypes.IBuffer, startIndex: number,
397397
return lines;
398398
}
399399

400+
export function isLikelyOnSameHost(lastCommand: string): boolean {
401+
if (lastCommand == null) {
402+
return true;
403+
}
404+
const cmd = lastCommand.trimStart();
405+
return !cmd.startsWith("ssh ");
406+
}
407+
400408
export function quoteForPosixShell(filePath: string): string {
401409
return "'" + filePath.replace(/'/g, "'\\''") + "'";
402410
}

0 commit comments

Comments
 (0)