diff --git a/build/tfs/darwin/smoketest.sh b/build/tfs/darwin/smoketest.sh index ae756d8ca3545715667305f0c5d32806b946f7d4..18da9dabf382b2b8d66c214eddf2d9627b6e4581 100755 --- a/build/tfs/darwin/smoketest.sh +++ b/build/tfs/darwin/smoketest.sh @@ -24,4 +24,11 @@ step "Run unit tests" \ ./scripts/test.sh --build --reporter dot step "Run integration tests" \ - ./scripts/test-integration.sh \ No newline at end of file + ./scripts/test-integration.sh + +step "Run smoke test" \ + pushd test/smoke + npm install + npm run compile + node src/main.js --latest "$AGENT_BUILDDIRECTORY/VSCode-darwin/Visual Studio Code - Insiders.app/Contents/MacOS/Electron" + popd \ No newline at end of file diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 228550b57afe7003b4fa48b90f11174174037cfd..2915bcb44bb07a29f744b34a4b256d81d5fd17a2 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -1041,3 +1041,8 @@ export function domContentLoaded(): TPromise { } }); } + +export function hintGPULayer(target: HTMLElement): void { + // This is to hint browsers that this dom node is suited to live in its own layer (e.g. sliders, etc.) + (target.style).willChange = 'transform'; +} diff --git a/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts b/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts index c7194cbc5c5757baa6ad5bcf46886b6b642675b4..7a8743cb62a27c4707b036436acab2b85c1dffe1 100644 --- a/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +++ b/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts @@ -170,6 +170,7 @@ export abstract class AbstractScrollbar extends Widget { this.domNode.setTransform('translate3d(0px, 0px, 0px)'); } else { this.domNode.setTransform(''); + DomUtils.hintGPULayer(this.domNode.domNode); } this._renderDomNode(this._scrollbarState.getRectangleLargeSize(), this._scrollbarState.getRectangleSmallSize()); diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index e380ac9bd3921553a078a7de56da8c973fc2f628..c063ec34f7bbe9977b5dd1a7ebb91a0e46054eff 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -17,7 +17,7 @@ import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingReso import { IKeybindingEvent, KeybindingSource, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IConfirmation, IMessageService } from 'vs/platform/message/common/message'; -import { IWorkspaceContextService, Workspace, IWorkspace } from 'vs/platform/workspace/common/workspace'; +import { IWorkspaceContextService, Workspace, IWorkspace, IWorkspace2 } from 'vs/platform/workspace/common/workspace'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser'; import { Selection } from 'vs/editor/common/core/selection'; @@ -495,8 +495,8 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { public _serviceBrand: any; - private readonly _onDidChangeFolders: Emitter = new Emitter(); - public readonly onDidChangeFolders: Event = this._onDidChangeFolders.event; + private readonly _onDidChangeWorkspaceRoots: Emitter = new Emitter(); + public readonly onDidChangeWorkspaceRoots: Event = this._onDidChangeWorkspaceRoots.event; private readonly folders: URI[]; @@ -512,6 +512,10 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { return this.workspace; } + public getWorkspace2(): IWorkspace2 { + return this.workspace ? { id: `${this.workspace.uid}`, roots: [this.workspace.resource] } : void 0; + } + public hasWorkspace(): boolean { return !!this.workspace; } diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 676300944f101ac50f199a887355ec7c10dba2ca..70cb44e1523cb2ba386f3a28d5ebcb015b4df865 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -413,6 +413,7 @@ export class Minimap extends ViewPart { this._slider = createFastDomNode(document.createElement('div')); this._slider.setPosition('absolute'); this._slider.setClassName('minimap-slider'); + dom.hintGPULayer(this._slider.domNode); this._domNode.appendChild(this._slider); this._tokensColorTracker = MinimapTokensColorTracker.getInstance(); @@ -614,10 +615,41 @@ export class Minimap extends ViewPart { this._slider.setTop(layout.sliderTop); this._slider.setHeight(layout.sliderHeight); + this._lastRenderData = this.renderLines(layout); + } + + private renderLines(layout: MinimapLayout): RenderData { + const renderMinimap = this._options.renderMinimap; const startLineNumber = layout.startLineNumber; const endLineNumber = layout.endLineNumber; const minimapLineHeight = getMinimapLineHeight(renderMinimap); + // Check if nothing changed w.r.t. lines from last frame + if (this._lastRenderData) { + const _lastData = this._lastRenderData._get(); + const lastStartLineNumber = _lastData.rendLineNumberStart; + const lastLines = _lastData.lines; + const lastLinesLength = lastLines.length; + + let linesNeedPainting = false; + for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) { + const lastLineIndex = lineNumber - lastStartLineNumber; + const source_dy = (lastLineIndex >= 0 && lastLineIndex < lastLinesLength ? lastLines[lastLineIndex].dy : -1); + + if (source_dy === -1) { + linesNeedPainting = true; + break; + } + } + + if (!linesNeedPainting) { + // Nice!! Nothing changed from last frame + return new RenderData(layout, _lastData.imageData, _lastData.lines); + } + } + + // Oh well!! We need to repaint some lines... + const imageData = this._getBuffer(); // Render untouched lines by using last rendered data. @@ -656,16 +688,16 @@ export class Minimap extends ViewPart { dy += minimapLineHeight; } + // Finally, paint to the canvas + const ctx = this._canvas.domNode.getContext('2d'); + ctx.putImageData(imageData, 0, 0); + // Save rendered data for reuse on next frame if possible - this._lastRenderData = new RenderData( + return new RenderData( layout, imageData, renderedLines ); - - // Finally, paint to the canvas - const ctx = this._canvas.domNode.getContext('2d'); - ctx.putImageData(imageData, 0, 0); } private static _renderUntouchedLines( diff --git a/src/vs/editor/contrib/comment/common/blockCommentCommand.ts b/src/vs/editor/contrib/comment/common/blockCommentCommand.ts index ffceef3758fb43027a7493e34f79235b3b150a58..d123d1f9d580df9a85175b48628d5afc884e23ca 100644 --- a/src/vs/editor/contrib/comment/common/blockCommentCommand.ts +++ b/src/vs/editor/contrib/comment/common/blockCommentCommand.ts @@ -97,16 +97,16 @@ export class BlockCommentCommand implements editorCommon.ICommand { if (!Range.isEmpty(r)) { // Insert block comment start - res.push(EditOperation.insert(new Position(r.startLineNumber, r.startColumn), startToken)); + res.push(EditOperation.insert(new Position(r.startLineNumber, r.startColumn), startToken + ' ')); // Insert block comment end - res.push(EditOperation.insert(new Position(r.endLineNumber, r.endColumn), endToken)); + res.push(EditOperation.insert(new Position(r.endLineNumber, r.endColumn), ' ' + endToken)); } else { // Insert both continuously res.push(EditOperation.replace(new Range( r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn - ), startToken + endToken)); + ), startToken + ' ' + endToken)); } return res; @@ -145,7 +145,7 @@ export class BlockCommentCommand implements editorCommon.ICommand { ); } else { var srcRange = inverseEditOperations[0].range; - var deltaColumn = this._usedEndToken ? -this._usedEndToken.length : 0; + var deltaColumn = this._usedEndToken ? -this._usedEndToken.length - 1 : 0; // minus 1 space before endToken return new Selection( srcRange.endLineNumber, srcRange.endColumn + deltaColumn, diff --git a/src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts b/src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts index 8f8f2cae11807633a9fdfff75fbe40ead9e98f32..1bd3597b7ac7d0e26cac9f593cd25c761f4ad100 100644 --- a/src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts +++ b/src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts @@ -28,13 +28,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(1, 3, 1, 3), [ - 'fi<00>rst', + 'fi<0 0>rst', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 5, 1, 5) + new Selection(1, 6, 1, 6) ); }); @@ -49,13 +49,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(2, 1, 1, 1), [ - '<0first', - '0>\tsecond line', + '<0 first', + ' 0>\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 3, 2, 1) + new Selection(1, 4, 2, 1) ); }); @@ -70,13 +70,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(1, 6, 1, 1), [ - '<0first0>', + '<0 first 0>', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 3, 1, 8) + new Selection(1, 4, 1, 9) ); testBlockCommentCommand( @@ -110,13 +110,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(1, 6, 1, 3), [ - 'fi<0rst0>', + 'fi<0 rst 0>', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 5, 1, 8) + new Selection(1, 6, 1, 9) ); }); @@ -131,13 +131,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(1, 6, 1, 3), [ - 'fi<0rst0>', + 'fi<0 rst 0>', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 5, 1, 8) + new Selection(1, 6, 1, 9) ); testBlockCommentCommand( @@ -171,13 +171,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(2, 4, 1, 1), [ - '<0first', - '\tse0>cond line', + '<0 first', + '\tse 0>cond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 3, 2, 4) + new Selection(1, 4, 2, 4) ); }); @@ -192,13 +192,13 @@ suite('Editor Contrib - Block Comment Command', () => { ], new Selection(2, 4, 1, 1), [ - '<0first', - '\tse0>cond line', + '<0 first', + '\tse 0>cond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 3, 2, 4) + new Selection(1, 4, 2, 4) ); testBlockCommentCommand( diff --git a/src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts b/src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts index 64d900f1dd7fba6683baa05f36956dc0958d25b3..098872864e5abfc20252f0ff8ede1b3d41b276bd 100644 --- a/src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts +++ b/src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts @@ -544,13 +544,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => { ], new Selection(1, 1, 1, 1), [ - '(first)', + '( first )', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 2, 1, 2) + new Selection(1, 3, 1, 3) ); }); @@ -586,13 +586,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => { ], new Selection(1, 1, 1, 1), [ - '(first)', + '( first )', '\tsecond line', 'third line', 'fourth line', 'fifth' ], - new Selection(1, 2, 1, 2) + new Selection(1, 3, 1, 3) ); }); @@ -607,13 +607,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => { ], new Selection(3, 2, 1, 3), [ - '(first', + '( first', '\tsecond line', - 'third line)', + 'third line )', 'fourth line', 'fifth' ], - new Selection(1, 4, 3, 2) + new Selection(1, 5, 3, 2) ); testLineCommentCommand( @@ -655,7 +655,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => { ], new Selection(1, 1, 1, 1), [ - '\t\t', + '\t\t', '\t\tsecond line', '\tthird line', 'fourth line', @@ -809,8 +809,8 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => { ], new Selection(1, 1, 3, 1), [ - ' ', + ' ', '' ], new Selection(1, 1, 3, 1) @@ -927,13 +927,13 @@ suite('Editor Contrib - Line Comment in mixed modes', () => { [ 'import React from \'react\';', 'const Loader = () => (', - ' {/*
*/}', + ' {/*
*/}', ' Loading...', '
', ');', 'export default Loader;' ], - new Selection(3, 7, 3, 7), + new Selection(3, 8, 3, 8), ); }); diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index a1ccdac3e62f37a3c6da3786c395b387d97dd51b..8e1b08ed1437c7faf1bcb4687f9d0f8c3a3bd9a4 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -27,6 +27,17 @@ export interface IWorkspaceContextService { */ getWorkspace(): IWorkspace; + /** + * Provides access to the workspace object the platform is running with. This may be null if the workbench was opened + * without workspace (empty); + */ + getWorkspace2(): IWorkspace2; + + /** + * An event which fires on workspace roots change. + */ + onDidChangeWorkspaceRoots: Event; + /** * Returns iff the provided resource is inside the workspace or not. */ @@ -44,11 +55,6 @@ export interface IWorkspaceContextService { */ toResource: (workspaceRelativePath: string) => URI; - /** - * TODO@Ben multiroot - */ - getFolders(): URI[]; - onDidChangeFolders: Event; } export interface IWorkspace { @@ -72,6 +78,20 @@ export interface IWorkspace { name?: string; } +export interface IWorkspace2 { + + /** + * the unique identifier of the workspace. + */ + readonly id: string; + + /** + * Mutliple roots in this workspace. First entry is master and never changes. + */ + readonly roots: URI[]; + +} + export class Workspace implements IWorkspace { constructor(private _resource: URI, private _uid?: number, private _name?: string) { @@ -105,9 +125,9 @@ export class Workspace implements IWorkspace { return null; } - public toResource(workspaceRelativePath: string): URI { + public toResource(workspaceRelativePath: string, root?: URI): URI { if (typeof workspaceRelativePath === 'string') { - return URI.file(paths.join(this._resource.fsPath, workspaceRelativePath)); + return URI.file(paths.join(root ? root.fsPath : this._resource.fsPath, workspaceRelativePath)); } return null; diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index f7cd4fb7e91cdd80e68c54de73341c03eaf62135..f6fc31c91ef6713a33374a47539e12e038e8e070 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -37,7 +37,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape { ) { super(); this._proxy = threadService.get(ExtHostContext.ExtHostWorkspace); - this._contextService.onDidChangeFolders(this._onDidChangeWorkspace, this, this._toDispose); + this._contextService.onDidChangeWorkspaceRoots(this._onDidChangeWorkspace, this, this._toDispose); } // --- workspace --- diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index b450e6538e6300897b7d55038fe1dddd6be6ba55..9f3ed92538c46c47aa9506c01eac00853e70dccb 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -408,7 +408,7 @@ export function createApiFactory( onWillSaveTextDocument: (listener, thisArgs?, disposables?) => { return extHostDocumentSaveParticipant.onWillSaveTextDocumentEvent(listener, thisArgs, disposables); }, - onDidChangeConfiguration: (listener: () => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => { + onDidChangeConfiguration: (listener: (_: any) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => { return extHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables); }, getConfiguration: (section?: string): vscode.WorkspaceConfiguration => { diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts index 9d40839b17791c1b6d6ed2362ff08f1d5cde8433..8a87e5126c07fe3e2ca86b0dc9de87d8207eb6b2 100644 --- a/src/vs/workbench/api/node/extHostSCM.ts +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -316,14 +316,14 @@ export class ExtHostSCM { return sourceControl; } - $provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise { + $provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise { const sourceControl = this._sourceControls.get(sourceControlHandle); if (!sourceControl || !sourceControl.quickDiffProvider) { return TPromise.as(null); } - return asWinJsPromise(token => sourceControl.quickDiffProvider.provideOriginalResource(uri, token)); + return asWinJsPromise(token => URI.parse(sourceControl.quickDiffProvider.provideOriginalResource(uri, token).toString())); } $onActiveSourceControlChange(handle: number): TPromise { diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index 75f4d49aa705613f98b158fc5523df1b6129e562..e24e7c1dc4a4d7c450b75dfd0809fe518e42f15a 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -293,6 +293,11 @@ export class ActivitybarPart extends Part implements IActivityBarService { } private updateViewletSwitcher() { + if (!this.viewletSwitcherBar) { + // We have not been rendered yet so there is nothing to update. + return; + } + let viewletsToShow = this.getPinnedViewlets(); // Always show the active viewlet even if it is marked to be hidden diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index 4f0baaf5ba0ffc14578eeb13c780b75f506d9769..f449677e86595e12bbea868a9dd23a30ba26a304 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -17,7 +17,7 @@ import { Schemas } from "vs/base/common/network"; import { RunOnceScheduler } from 'vs/base/common/async'; import { readFile } from 'vs/base/node/pfs'; import * as extfs from 'vs/base/node/extfs'; -import { IWorkspaceContextService, Workspace, IWorkspace } from "vs/platform/workspace/common/workspace"; +import { IWorkspaceContextService, IWorkspace2, Workspace as SingleRootWorkspace, IWorkspace } from "vs/platform/workspace/common/workspace"; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { FileChangeType, FileChangesEvent, isEqual } from 'vs/platform/files/common/files'; import { ConfigModel } from 'vs/platform/configuration/common/model'; @@ -44,14 +44,29 @@ interface IWorkspaceConfiguration { type IWorkspaceFoldersConfiguration = { [rootFolder: string]: { folders: string[]; } }; +class Workspace implements IWorkspace2 { + + constructor(readonly id: string, private _roots: URI[]) { + } + + get roots(): URI[] { + return this._roots; + } + + setRoots(roots: URI[]): void { + this._roots = roots; + } + +} + export class WorkspaceConfigurationService extends Disposable implements IWorkspaceContextService, IWorkspaceConfigurationService { private static RELOAD_CONFIGURATION_DELAY = 50; public _serviceBrand: any; - private readonly _onDidChangeFolders: Emitter = this._register(new Emitter()); - public readonly onDidChangeFolders: Event = this._onDidChangeFolders.event; + private readonly _onDidChangeWorkspaceRoots: Emitter = this._register(new Emitter()); + public readonly onDidChangeWorkspaceRoots: Event = this._onDidChangeWorkspaceRoots.event; private readonly _onDidUpdateConfiguration: Emitter = this._register(new Emitter()); public readonly onDidUpdateConfiguration: Event = this._onDidUpdateConfiguration.event; @@ -65,12 +80,12 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp private workspaceFilePathToConfiguration: { [relativeWorkspacePath: string]: TPromise> }; private reloadConfigurationScheduler: RunOnceScheduler; - private folders: URI[]; + private readonly workspace: Workspace; - constructor(private environmentService: IEnvironmentService, private workspace?: Workspace, private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME) { + constructor(private environmentService: IEnvironmentService, private singleRootWorkspace?: SingleRootWorkspace, private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME) { super(); - this.folders = workspace ? [workspace.resource] : []; + this.workspace = singleRootWorkspace ? new Workspace(`${singleRootWorkspace.uid}`, [singleRootWorkspace.resource]) : null; this.workspaceFilePathToConfiguration = Object.create(null); this.cachedConfig = new ConfigModel(null); @@ -95,10 +110,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp } // Resovled configured folders for workspace - let configuredFolders: URI[] = [this.workspace.resource]; + let [master] = this.workspace.roots; + let configuredFolders: URI[] = [master]; const config = this.getConfiguration('workspace'); if (config) { - const workspaceConfig = config[this.workspace.resource.toString()]; + const workspaceConfig = config[master.toString()]; if (workspaceConfig) { const additionalFolders = workspaceConfig.folders .map(f => URI.parse(f)) @@ -112,20 +128,20 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp configuredFolders = distinct(configuredFolders, r => r.toString()); // Find changes - const changed = !equals(this.folders, configuredFolders, (r1, r2) => r1.toString() === r2.toString()); + const changed = !equals(this.workspace.roots, configuredFolders, (r1, r2) => r1.toString() === r2.toString()); - this.folders = configuredFolders; + this.workspace.setRoots(configuredFolders); if (notify && changed) { - this._onDidChangeFolders.fire(configuredFolders); + this._onDidChangeWorkspaceRoots.fire(configuredFolders); } } - public getFolders(): URI[] { - return this.folders; + public getWorkspace(): IWorkspace { + return this.singleRootWorkspace; } - public getWorkspace(): IWorkspace { + public getWorkspace2(): IWorkspace2 { return this.workspace; } @@ -134,15 +150,15 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp } public isInsideWorkspace(resource: URI): boolean { - return this.workspace ? this.workspace.isInsideWorkspace(resource) : false; + return this.workspace ? this.singleRootWorkspace.isInsideWorkspace(resource) : false; } public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string { - return this.workspace ? this.workspace.toWorkspaceRelativePath(resource, toOSPath) : null; + return this.workspace ? this.singleRootWorkspace.toWorkspaceRelativePath(resource, toOSPath) : null; } public toResource(workspaceRelativePath: string): URI { - return this.workspace ? this.workspace.toResource(workspaceRelativePath) : null; + return this.workspace ? this.singleRootWorkspace.toResource(workspaceRelativePath) : null; } private onBaseConfigurationChanged(event: IConfigurationServiceEvent): void { @@ -276,7 +292,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp // once: when invoked for the first time we fetch json files that contribute settings if (!this.bulkFetchFromWorkspacePromise) { - this.bulkFetchFromWorkspacePromise = resolveStat(this.workspace.toResource(this.workspaceSettingsRootFolder)).then(stat => { + this.bulkFetchFromWorkspacePromise = resolveStat(this.toResource(this.workspaceSettingsRootFolder)).then(stat => { if (!stat.isDirectory) { return TPromise.as([]); } @@ -287,11 +303,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp return false; // only JSON files } - return this.isWorkspaceConfigurationFile(this.workspace.toWorkspaceRelativePath(stat.resource)); // only workspace config files + return this.isWorkspaceConfigurationFile(this.toWorkspaceRelativePath(stat.resource)); // only workspace config files }).map(stat => stat.resource)); }, err => [] /* never fail this call */) .then((contents: IContent[]) => { - contents.forEach(content => this.workspaceFilePathToConfiguration[this.workspace.toWorkspaceRelativePath(content.resource)] = TPromise.as(this.createConfigModel(content))); + contents.forEach(content => this.workspaceFilePathToConfiguration[this.toWorkspaceRelativePath(content.resource)] = TPromise.as(this.createConfigModel(content))); }, errors.onUnexpectedError); } @@ -317,7 +333,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp continue; // only JSON files or the actual settings folder } - const workspacePath = this.workspace.toWorkspaceRelativePath(resource); + const workspacePath = this.toWorkspaceRelativePath(resource); if (!workspacePath) { continue; // event is not inside workspace } @@ -353,7 +369,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp } private createConfigModel(content: IContent): IConfigModel { - const path = this.workspace.toWorkspaceRelativePath(content.resource); + const path = this.toWorkspaceRelativePath(content.resource); if (path === WORKSPACE_CONFIG_DEFAULT_PATH) { return new WorkspaceSettingsConfigModel(content.value, content.resource.toString()); } else { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index c280cd4c979354c4d0e2c52f5ddc874d6a991f6d..dc3c013b40461bab71c3ea45eac9e00c694de64c 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -27,7 +27,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { IEditorInput, IEditorOptions, Position, Direction, IEditor, IResourceInput } from 'vs/platform/editor/common/editor'; import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IMessageService, IConfirmation } from 'vs/platform/message/common/message'; -import { IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IWorkspace, IWorkspaceContextService, IWorkspace2 } from 'vs/platform/workspace/common/workspace'; import { ILifecycleService, ShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; @@ -66,16 +66,16 @@ export class TestContextService implements IWorkspaceContextService { private workspace: any; private options: any; - private _onDidChangeFolders: Emitter; + private _onDidChangeWorkspaceRoots: Emitter; constructor(workspace: any = TestWorkspace, options: any = null) { this.workspace = workspace; this.options = options || Object.create(null); - this._onDidChangeFolders = new Emitter(); + this._onDidChangeWorkspaceRoots = new Emitter(); } - public get onDidChangeFolders(): Event { - return this._onDidChangeFolders.event; + public get onDidChangeWorkspaceRoots(): Event { + return this._onDidChangeWorkspaceRoots.event; } public getFolders(): URI[] { @@ -90,6 +90,10 @@ export class TestContextService implements IWorkspaceContextService { return this.workspace; } + public getWorkspace2(): IWorkspace2 { + return this.workspace ? { id: `${this.workspace.uid}`, roots: [this.workspace.resource] } : void 0; + } + public setWorkspace(workspace: any): void { this.workspace = workspace; }