mirror of
https://github.com/microsoft/vscode.git
synced 2026-03-05 00:08:14 +00:00
make window finder fit for workspaces
This commit is contained in:
@@ -8,9 +8,15 @@ import assert = require('assert');
|
||||
import path = require('path');
|
||||
import { findBestWindowOrFolderForFile, ISimpleWindow, IBestWindowOrFolderOptions } from 'vs/code/node/windowsFinder';
|
||||
import { OpenContext } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces";
|
||||
|
||||
const fixturesFolder = require.toUrl('./fixtures');
|
||||
|
||||
const testWorkspace: IWorkspaceIdentifier = {
|
||||
id: Date.now().toString(),
|
||||
configPath: path.join(fixturesFolder, 'workspaces.json')
|
||||
};
|
||||
|
||||
function options(custom?: Partial<IBestWindowOrFolderOptions<ISimpleWindow>>): IBestWindowOrFolderOptions<ISimpleWindow> {
|
||||
return {
|
||||
windows: [],
|
||||
@@ -18,6 +24,7 @@ function options(custom?: Partial<IBestWindowOrFolderOptions<ISimpleWindow>>): I
|
||||
reuseWindow: false,
|
||||
context: OpenContext.CLI,
|
||||
codeSettingsFolder: '_vscode',
|
||||
workspaceResolver: workspace => { return workspace === testWorkspace ? { id: testWorkspace.id, folders: [path.join(fixturesFolder, 'vscode_workspace_1_folder'), path.join(fixturesFolder, 'vscode_workspace_2_folder')] } : null; },
|
||||
...custom
|
||||
};
|
||||
}
|
||||
@@ -152,4 +159,12 @@ suite('WindowsFinder', () => {
|
||||
userHome: path.join(fixturesFolder, 'vscode_home_folder')
|
||||
})), path.join(fixturesFolder, 'vscode_home_folder'));
|
||||
});
|
||||
|
||||
test('Workspace folder wins', () => {
|
||||
const window = { lastFocusTime: 1, openedWorkspace: testWorkspace };
|
||||
assert.equal(findBestWindowOrFolderForFile(options({
|
||||
windows: [window],
|
||||
filePath: path.join(fixturesFolder, 'vscode_workspace_2_folder', 'nested_vscode_folder', 'subfolder', 'file.txt')
|
||||
})), window);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user