wire in support for opening workspace config from the main side

This commit is contained in:
Benjamin Pasero
2017-07-11 12:23:33 +02:00
parent ef50310eba
commit 272a28828a
10 changed files with 438 additions and 120 deletions
+23 -12
View File
@@ -12,7 +12,8 @@ import * as paths from 'vs/base/common/paths';
import { OpenContext } from 'vs/platform/windows/common/windows';
export interface ISimpleWindow {
openedFolderPath: string;
openedWorkspaceConfigPath?: string;
openedFolderPath?: string;
openedFilePath?: string;
extensionDevelopmentPath?: string;
lastFocusTime: number;
@@ -107,17 +108,7 @@ export function getLastActiveWindow<W extends ISimpleWindow>(windows: W[]): W {
export function findWindowOnFolder<W extends ISimpleWindow>(windows: W[], folderPath: string): W {
if (windows.length) {
// Sort the last active window to the front of the array of windows to test
const windowsToTest = windows.slice(0);
const lastActiveWindow = getLastActiveWindow(windows);
if (lastActiveWindow) {
windowsToTest.splice(windowsToTest.indexOf(lastActiveWindow), 1);
windowsToTest.unshift(lastActiveWindow);
}
// Find it
const res = windowsToTest.filter(w => {
const res = windows.filter(w => {
// match on folder
if (typeof w.openedFolderPath === 'string' && (paths.isEqual(w.openedFolderPath, folderPath, !platform.isLinux /* ignorecase */))) {
@@ -135,6 +126,26 @@ export function findWindowOnFolder<W extends ISimpleWindow>(windows: W[], folder
return null;
}
export function findWindowOnWorkspace<W extends ISimpleWindow>(windows: W[], workspaceConfigPath: string): W {
if (windows.length) {
const res = windows.filter(w => {
// match on workspace
if (typeof w.openedWorkspaceConfigPath === 'string' && (paths.isEqual(w.openedWorkspaceConfigPath, workspaceConfigPath, !platform.isLinux /* ignorecase */))) {
return true;
}
return false;
});
if (res && res.length) {
return res[0];
}
}
return null;
}
export function findExtensionDevelopmentWindow<W extends ISimpleWindow>(windows: W[], extensionDevelopmentPath?: string): W {
if (windows.length) {
const res = windows.filter(w => {