Open workspace files in desktop targets
This commit is contained in:
@@ -193,6 +193,31 @@ function getWorkspaceScripts(
|
||||
return workspaceDescriptor?.scripts ?? EMPTY_WORKSPACE_SCRIPTS;
|
||||
}
|
||||
|
||||
interface WorkspaceFileLocationFields {
|
||||
path: string | null;
|
||||
lineStart?: number;
|
||||
lineEnd?: number;
|
||||
}
|
||||
|
||||
function getWorkspaceFileLocationFields(
|
||||
tab: WorkspaceTabDescriptor | null,
|
||||
): WorkspaceFileLocationFields {
|
||||
const target = tab?.target;
|
||||
if (target?.kind !== "file") {
|
||||
return { path: null };
|
||||
}
|
||||
return { path: target.path, lineStart: target.lineStart, lineEnd: target.lineEnd };
|
||||
}
|
||||
|
||||
function buildWorkspaceFileLocation(
|
||||
fields: WorkspaceFileLocationFields,
|
||||
): WorkspaceFileLocation | null {
|
||||
if (fields.path === null) {
|
||||
return null;
|
||||
}
|
||||
return { path: fields.path, lineStart: fields.lineStart, lineEnd: fields.lineEnd };
|
||||
}
|
||||
|
||||
const ThemedActivityIndicator = withUnistyles(ActivityIndicator);
|
||||
const ThemedEllipsis = withUnistyles(Ellipsis);
|
||||
const ThemedEllipsisVertical = withUnistyles(EllipsisVertical);
|
||||
@@ -2851,6 +2876,19 @@ function WorkspaceScreenContent({
|
||||
});
|
||||
|
||||
const activeTabDescriptor = useMemo(() => activeTab?.descriptor ?? null, [activeTab]);
|
||||
const activeFileFields = getWorkspaceFileLocationFields(activeTabDescriptor);
|
||||
const activeFilePath = activeFileFields.path;
|
||||
const activeFileLineStart = activeFileFields.lineStart;
|
||||
const activeFileLineEnd = activeFileFields.lineEnd;
|
||||
const activeFileLocation = useMemo<WorkspaceFileLocation | null>(
|
||||
() =>
|
||||
buildWorkspaceFileLocation({
|
||||
path: activeFilePath,
|
||||
lineStart: activeFileLineStart,
|
||||
lineEnd: activeFileLineEnd,
|
||||
}),
|
||||
[activeFileLineEnd, activeFileLineStart, activeFilePath],
|
||||
);
|
||||
const canRenderDesktopPaneSplits = supportsDesktopPaneSplits();
|
||||
const shouldRenderDesktopPaneFallback = useMemo(
|
||||
() => !isMobile && !canRenderDesktopPaneSplits,
|
||||
@@ -3083,10 +3121,11 @@ function WorkspaceScreenContent({
|
||||
hideLabels={showCompactButtonLabels}
|
||||
/>
|
||||
) : null}
|
||||
{!isMobile ? (
|
||||
{!isMobile && workspaceDirectory ? (
|
||||
<WorkspaceOpenInEditorButton
|
||||
serverId={normalizedServerId}
|
||||
cwd={normalizedWorkspaceId}
|
||||
cwd={workspaceDirectory}
|
||||
activeFile={activeFileLocation}
|
||||
hideLabels={showCompactButtonLabels}
|
||||
/>
|
||||
) : null}
|
||||
@@ -3193,6 +3232,8 @@ function WorkspaceScreenContent({
|
||||
workspaceDescriptor,
|
||||
normalizedServerId,
|
||||
normalizedWorkspaceId,
|
||||
workspaceDirectory,
|
||||
activeFileLocation,
|
||||
liveTerminalIds,
|
||||
handleScriptTerminalStarted,
|
||||
handleViewScriptTerminal,
|
||||
|
||||
Reference in New Issue
Block a user