allow remote workspaces

This commit is contained in:
Martin Aeschlimann
2019-01-25 17:04:03 +01:00
parent 7efcf23bbd
commit b5b21eada0
21 changed files with 190 additions and 169 deletions
+17 -8
View File
@@ -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;
}