mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-27 02:37:26 +01:00
allow remote workspaces
This commit is contained in:
@@ -21,7 +21,6 @@ export interface ISimpleWindow {
|
||||
export interface IBestWindowOrFolderOptions<W extends ISimpleWindow> {
|
||||
windows: W[];
|
||||
newWindow: boolean;
|
||||
reuseWindow: boolean;
|
||||
context: OpenContext;
|
||||
fileUri?: URI;
|
||||
userHome?: string;
|
||||
@@ -29,7 +28,7 @@ export interface IBestWindowOrFolderOptions<W extends ISimpleWindow> {
|
||||
workspaceResolver: (workspace: IWorkspaceIdentifier) => IResolvedWorkspace | null;
|
||||
}
|
||||
|
||||
export function findBestWindowOrFolderForFile<W extends ISimpleWindow>({ windows, newWindow, reuseWindow, context, fileUri, workspaceResolver }: IBestWindowOrFolderOptions<W>): W | null {
|
||||
export function findBestWindowOrFolderForFile<W extends ISimpleWindow>({ windows, newWindow, context, fileUri, workspaceResolver }: IBestWindowOrFolderOptions<W>): W | null {
|
||||
if (!newWindow && fileUri && (context === OpenContext.DESKTOP || context === OpenContext.CLI || context === OpenContext.DOCK)) {
|
||||
const windowOnFilePath = findWindowOnFilePath(windows, fileUri, workspaceResolver);
|
||||
if (windowOnFilePath) {
|
||||
@@ -42,11 +41,21 @@ export function findBestWindowOrFolderForFile<W extends ISimpleWindow>({ windows
|
||||
function findWindowOnFilePath<W extends ISimpleWindow>(windows: W[], fileUri: URI, workspaceResolver: (workspace: IWorkspaceIdentifier) => IResolvedWorkspace | null): W | null {
|
||||
|
||||
// First check for windows with workspaces that have a parent folder of the provided path opened
|
||||
const workspaceWindows = windows.filter(window => !!window.openedWorkspace);
|
||||
for (const window of workspaceWindows) {
|
||||
const resolvedWorkspace = workspaceResolver(window.openedWorkspace!);
|
||||
if (resolvedWorkspace && resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri))) {
|
||||
return window;
|
||||
for (const window of windows) {
|
||||
const workspace = window.openedWorkspace;
|
||||
if (workspace) {
|
||||
const resolvedWorkspace = workspaceResolver(workspace);
|
||||
if (resolvedWorkspace) {
|
||||
// workspace cpuld be resolved: It's in the local file system
|
||||
if (resolvedWorkspace.folders.some(folder => isEqualOrParent(fileUri, folder.uri))) {
|
||||
return window;
|
||||
}
|
||||
} else {
|
||||
// use the config path instead
|
||||
if (isEqualOrParent(fileUri, workspace.configPath)) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +111,7 @@ export function findWindowOnWorkspaceOrFolderUri<W extends ISimpleWindow>(window
|
||||
}
|
||||
for (const window of windows) {
|
||||
// check for workspace config path
|
||||
if (window.openedWorkspace && isEqual(URI.file(window.openedWorkspace.configPath), uri, !platform.isLinux /* ignorecase */)) {
|
||||
if (window.openedWorkspace && isEqual(window.openedWorkspace.configPath, uri)) {
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user