mirror of
https://github.com/wavetermdev/waveterm
synced 2026-04-21 14:37:16 +00:00
loosen up the requirements to show the File Browser in term context menu (#3232)
This commit is contained in:
parent
4969ee19b8
commit
3e4fe8cf51
2 changed files with 11 additions and 3 deletions
|
|
@ -40,7 +40,7 @@ import { boundNumber, fireAndForget, stringToBase64 } from "@/util/util";
|
|||
import * as jotai from "jotai";
|
||||
import * as React from "react";
|
||||
import { getBlockingCommand } from "./shellblocking";
|
||||
import { computeTheme, DefaultTermTheme, trimTerminalSelection } from "./termutil";
|
||||
import { computeTheme, DefaultTermTheme, isLikelyOnSameHost, trimTerminalSelection } from "./termutil";
|
||||
import { TermWrap, WebGLSupported } from "./termwrap";
|
||||
|
||||
export class TermViewModel implements ViewModel {
|
||||
|
|
@ -958,9 +958,9 @@ export class TermViewModel implements ViewModel {
|
|||
});
|
||||
fullMenu.push({ type: "separator" });
|
||||
|
||||
const shellIntegrationStatus = globalStore.get(this.termRef?.current?.shellIntegrationStatusAtom);
|
||||
const lastCommand = globalStore.get(this.termRef?.current?.lastCommandAtom);
|
||||
const cwd = blockData?.meta?.["cmd:cwd"];
|
||||
const canShowFileBrowser = shellIntegrationStatus === "ready" && cwd != null;
|
||||
const canShowFileBrowser = cwd != null && isLikelyOnSameHost(lastCommand);
|
||||
|
||||
if (canShowFileBrowser) {
|
||||
fullMenu.push({
|
||||
|
|
|
|||
|
|
@ -397,6 +397,14 @@ export function bufferLinesToText(buffer: TermTypes.IBuffer, startIndex: number,
|
|||
return lines;
|
||||
}
|
||||
|
||||
export function isLikelyOnSameHost(lastCommand: string): boolean {
|
||||
if (lastCommand == null) {
|
||||
return true;
|
||||
}
|
||||
const cmd = lastCommand.trimStart();
|
||||
return !cmd.startsWith("ssh ");
|
||||
}
|
||||
|
||||
export function quoteForPosixShell(filePath: string): string {
|
||||
return "'" + filePath.replace(/'/g, "'\\''") + "'";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue