Skip to content

Commit d167728

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/vscode
2 parents 0df5b6f + 884bc1b commit d167728

23 files changed

Lines changed: 308 additions & 109 deletions

File tree

src/vs/base/browser/ui/selectBox/selectBox.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export class SelectBox extends Widget {
8585
if (this.selected >= 0) {
8686
this.select.selectedIndex = this.selected;
8787
this.select.title = this.options[this.selected];
88-
this._onDidSelect.fire(this.options[this.selected]);
8988
}
9089
}
9190

src/vs/base/common/iterator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ArrayIterator<T> implements IIterator<T> {
2424
}
2525

2626
public first(): T {
27-
this.index = this.start - 1;
27+
this.index = this.start;
2828
return this.current();
2929
}
3030

src/vs/code/electron-main/menus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export class VSCodeMenu {
383383
const closeWindow = new MenuItem(this.likeAction('workbench.action.closeWindow', { label: mnemonicLabel(nls.localize({ key: 'miCloseWindow', comment: ['&& denotes a mnemonic'] }, "Close &&Window")), click: () => this.windowsService.getLastActiveWindow().win.close(), enabled: this.windowsService.getWindowCount() > 0 }));
384384

385385
const closeFolder = this.createMenuItem(nls.localize({ key: 'miCloseFolder', comment: ['&& denotes a mnemonic'] }, "Close &&Folder"), 'workbench.action.closeFolder');
386-
const closeEditor = this.createMenuItem(nls.localize({ key: 'miCloseEditor', comment: ['&& denotes a mnemonic'] }, "Close &&Editor"), 'workbench.action.closeActiveEditor');
386+
const closeEditor = this.createMenuItem(nls.localize({ key: 'miCloseEditor', comment: ['&& denotes a mnemonic'] }, "&&Close Editor"), 'workbench.action.closeActiveEditor');
387387

388388
const exit = new MenuItem(this.likeAction('workbench.action.quit', { label: mnemonicLabel(nls.localize({ key: 'miExit', comment: ['&& denotes a mnemonic'] }, "E&&xit")), click: () => this.windowsService.quit() }));
389389

src/vs/code/electron-main/windows.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ export class WindowsManager implements IWindowsMainService {
323323
}
324324

325325
let foldersToOpen = arrays.distinct(iPathsToOpen.filter(iPath => iPath.workspacePath && !iPath.filePath).map(iPath => iPath.workspacePath), folder => platform.isLinux ? folder : folder.toLowerCase()); // prevent duplicates
326-
let foldersToRestore = (openConfig.initialStartup && !openConfig.cli.extensionDevelopmentPath) ? this.backupService.workspaceBackupPaths : [];
326+
let foldersToRestore = (openConfig.initialStartup && !openConfig.cli.extensionDevelopmentPath) ? this.backupService.getWorkspaceBackupPaths() : [];
327327
let filesToOpen: IPath[] = [];
328328
let filesToDiff: IPath[] = [];
329329
let emptyToOpen = iPathsToOpen.filter(iPath => !iPath.workspacePath && !iPath.filePath);
330-
let emptyToRestore = (openConfig.initialStartup && !openConfig.cli.extensionDevelopmentPath) ? this.backupService.emptyWorkspaceBackupPaths : [];
330+
let emptyToRestore = (openConfig.initialStartup && !openConfig.cli.extensionDevelopmentPath) ? this.backupService.getEmptyWorkspaceBackupPaths() : [];
331331
let filesToCreate = iPathsToOpen.filter(iPath => !!iPath.filePath && iPath.createFilePath);
332332

333333
// Diff mode needs special care

src/vs/platform/backup/common/backup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const IBackupService = createDecorator<IBackupService>('backupService');
1717
export interface IBackupMainService extends IBackupService {
1818
_serviceBrand: any;
1919

20-
workspaceBackupPaths: string[];
21-
emptyWorkspaceBackupPaths: string[];
20+
getWorkspaceBackupPaths(): string[];
21+
getEmptyWorkspaceBackupPaths(): string[];
2222

2323
registerWindowForBackupsSync(windowId: number, isEmptyWorkspace: boolean, backupFolder?: string, workspacePath?: string): void;
2424
}

src/vs/platform/backup/electron-main/backupMainService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ export class BackupMainService implements IBackupMainService {
3434
this.loadSync();
3535
}
3636

37-
public get workspaceBackupPaths(): string[] {
38-
return this.backups.folderWorkspaces;
37+
public getWorkspaceBackupPaths(): string[] {
38+
return this.backups.folderWorkspaces.slice(0); // return a copy
3939
}
4040

41-
public get emptyWorkspaceBackupPaths(): string[] {
42-
return this.backups.emptyWorkspaces;
41+
public getEmptyWorkspaceBackupPaths(): string[] {
42+
return this.backups.emptyWorkspaces.slice(0); // return a copy
4343
}
4444

4545
public getBackupPath(windowId: number): TPromise<string> {

src/vs/platform/backup/test/electron-main/backupMainService.test.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ suite('BackupMainService', () => {
8080
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
8181
service.registerWindowForBackupsSync(2, false, null, barFile.fsPath);
8282
service.loadSync();
83-
assert.deepEqual(service.workspaceBackupPaths, []);
83+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
8484

8585
// 2) backup workspace path exists with empty contents within
8686
fs.mkdirSync(service.toBackupPath(fooFile.fsPath));
8787
fs.mkdirSync(service.toBackupPath(barFile.fsPath));
8888
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
8989
service.registerWindowForBackupsSync(2, false, null, barFile.fsPath);
9090
service.loadSync();
91-
assert.deepEqual(service.workspaceBackupPaths, []);
91+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
9292
assert.ok(!fs.exists(service.toBackupPath(fooFile.fsPath)));
9393
assert.ok(!fs.exists(service.toBackupPath(barFile.fsPath)));
9494

@@ -100,7 +100,7 @@ suite('BackupMainService', () => {
100100
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
101101
service.registerWindowForBackupsSync(2, false, null, barFile.fsPath);
102102
service.loadSync();
103-
assert.deepEqual(service.workspaceBackupPaths, []);
103+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
104104
assert.ok(!fs.exists(service.toBackupPath(fooFile.fsPath)));
105105
assert.ok(!fs.exists(service.toBackupPath(barFile.fsPath)));
106106

@@ -111,101 +111,101 @@ suite('BackupMainService', () => {
111111
fs.mkdirSync(service.toBackupPath(barFile.fsPath));
112112
fs.mkdirSync(fileBackups);
113113
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
114-
assert.equal(service.workspaceBackupPaths.length, 1);
115-
assert.equal(service.emptyWorkspaceBackupPaths.length, 0);
114+
assert.equal(service.getWorkspaceBackupPaths().length, 1);
115+
assert.equal(service.getEmptyWorkspaceBackupPaths().length, 0);
116116
fs.writeFileSync(path.join(fileBackups, 'backup.txt'), '');
117117
service.loadSync();
118-
assert.equal(service.workspaceBackupPaths.length, 0);
119-
assert.equal(service.emptyWorkspaceBackupPaths.length, 1);
118+
assert.equal(service.getWorkspaceBackupPaths().length, 0);
119+
assert.equal(service.getEmptyWorkspaceBackupPaths().length, 1);
120120

121121
done();
122122
});
123123

124124
suite('loadSync', () => {
125-
test('workspaceBackupPaths should return [] when workspaces.json doesn\'t exist', () => {
126-
assert.deepEqual(service.workspaceBackupPaths, []);
125+
test('getWorkspaceBackupPaths() should return [] when workspaces.json doesn\'t exist', () => {
126+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
127127
});
128128

129-
test('workspaceBackupPaths should return [] when workspaces.json is not properly formed JSON', () => {
129+
test('getWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON', () => {
130130
fs.writeFileSync(backupWorkspacesPath, '');
131131
service.loadSync();
132-
assert.deepEqual(service.workspaceBackupPaths, []);
132+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
133133
fs.writeFileSync(backupWorkspacesPath, '{]');
134134
service.loadSync();
135-
assert.deepEqual(service.workspaceBackupPaths, []);
135+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
136136
fs.writeFileSync(backupWorkspacesPath, 'foo');
137137
service.loadSync();
138-
assert.deepEqual(service.workspaceBackupPaths, []);
138+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
139139
});
140140

141-
test('workspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is absent', () => {
141+
test('getWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is absent', () => {
142142
fs.writeFileSync(backupWorkspacesPath, '{}');
143143
service.loadSync();
144-
assert.deepEqual(service.workspaceBackupPaths, []);
144+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
145145
});
146146

147-
test('workspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array', () => {
147+
test('getWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array', () => {
148148
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":{}}');
149149
service.loadSync();
150-
assert.deepEqual(service.workspaceBackupPaths, []);
150+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
151151
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":{"foo": ["bar"]}}');
152152
service.loadSync();
153-
assert.deepEqual(service.workspaceBackupPaths, []);
153+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
154154
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":{"foo": []}}');
155155
service.loadSync();
156-
assert.deepEqual(service.workspaceBackupPaths, []);
156+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
157157
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":{"foo": "bar"}}');
158158
service.loadSync();
159-
assert.deepEqual(service.workspaceBackupPaths, []);
159+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
160160
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":"foo"}');
161161
service.loadSync();
162-
assert.deepEqual(service.workspaceBackupPaths, []);
162+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
163163
fs.writeFileSync(backupWorkspacesPath, '{"folderWorkspaces":1}');
164164
service.loadSync();
165-
assert.deepEqual(service.workspaceBackupPaths, []);
165+
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
166166
});
167167

168-
test('emptyWorkspaceBackupPaths should return [] when workspaces.json doesn\'t exist', () => {
169-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
168+
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json doesn\'t exist', () => {
169+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
170170
});
171171

172-
test('emptyWorkspaceBackupPaths should return [] when workspaces.json is not properly formed JSON', () => {
172+
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json is not properly formed JSON', () => {
173173
fs.writeFileSync(backupWorkspacesPath, '');
174174
service.loadSync();
175-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
175+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
176176
fs.writeFileSync(backupWorkspacesPath, '{]');
177177
service.loadSync();
178-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
178+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
179179
fs.writeFileSync(backupWorkspacesPath, 'foo');
180180
service.loadSync();
181-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
181+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
182182
});
183183

184-
test('emptyWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is absent', () => {
184+
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is absent', () => {
185185
fs.writeFileSync(backupWorkspacesPath, '{}');
186186
service.loadSync();
187-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
187+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
188188
});
189189

190-
test('emptyWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array', () => {
190+
test('getEmptyWorkspaceBackupPaths() should return [] when folderWorkspaces in workspaces.json is not a string array', () => {
191191
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{}}');
192192
service.loadSync();
193-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
193+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
194194
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": ["bar"]}}');
195195
service.loadSync();
196-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
196+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
197197
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": []}}');
198198
service.loadSync();
199-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
199+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
200200
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":{"foo": "bar"}}');
201201
service.loadSync();
202-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
202+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
203203
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":"foo"}');
204204
service.loadSync();
205-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
205+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
206206
fs.writeFileSync(backupWorkspacesPath, '{"emptyWorkspaces":1}');
207207
service.loadSync();
208-
assert.deepEqual(service.emptyWorkspaceBackupPaths, []);
208+
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
209209
});
210210
});
211211

@@ -232,10 +232,10 @@ suite('BackupMainService', () => {
232232
});
233233

234234
suite('registerWindowForBackups', () => {
235-
test('pushWorkspaceBackupPathsSync should persist paths to workspaces.json', () => {
235+
test('pushgetWorkspaceBackupPaths()Sync should persist paths to workspaces.json', () => {
236236
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
237237
service.registerWindowForBackupsSync(2, false, null, barFile.fsPath);
238-
assert.deepEqual(service.workspaceBackupPaths, [fooFile.fsPath, barFile.fsPath]);
238+
assert.deepEqual(service.getWorkspaceBackupPaths(), [fooFile.fsPath, barFile.fsPath]);
239239
pfs.readFile(backupWorkspacesPath, 'utf-8').then(buffer => {
240240
const json = <IBackupWorkspacesFormat>JSON.parse(buffer);
241241
assert.deepEqual(json.folderWorkspaces, [fooFile.fsPath, barFile.fsPath]);

src/vs/workbench/electron-browser/shell.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export class WorkbenchShell {
284284
// Telemetry: workspace tags
285285
const workspaceStats: WorkspaceStats = <WorkspaceStats>this.workbench.getInstantiationService().createInstance(WorkspaceStats);
286286
workspaceStats.reportWorkspaceTags(this.options);
287+
workspaceStats.reportCloudStats();
287288

288289
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
289290
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));

src/vs/workbench/parts/debug/browser/debugActionItems.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class StartDebugActionItem extends EventEmitter implements IActionItem {
3737
private registerListeners(): void {
3838
this.toDispose.push(this.configurationService.onDidUpdateConfiguration(e => {
3939
this.updateOptions();
40+
this.nameContainer.textContent = this.debugService.getViewModel().selectedConfigurationName;
4041
}));
4142
this.toDispose.push(this.selectBox.onDidSelect(configurationName => {
4243
this.debugService.getViewModel().setSelectedConfigurationName(configurationName);
@@ -93,6 +94,8 @@ export class StartDebugActionItem extends EventEmitter implements IActionItem {
9394
const selected = options.indexOf(this.debugService.getViewModel().selectedConfigurationName);
9495
this.selectBox.setOptions(options, selected);
9596
}
97+
98+
this.debugService.getViewModel().setSelectedConfigurationName(this.selectBox.getSelected());
9699
}
97100
}
98101

src/vs/workbench/parts/explorers/browser/treeExplorerViewlet.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class TreeExplorerViewlet extends Viewlet {
3232

3333
this.viewletState = new TreeExplorerViewletState();
3434
this.viewletId = viewletId;
35-
this.treeNodeProviderId = this.getTreeProviderName(viewletId);
35+
36+
const tokens = viewletId.split('.');
37+
this.treeNodeProviderId = tokens[tokens.length - 1];
3638
}
3739

3840
public getId(): string {
@@ -63,19 +65,34 @@ export class TreeExplorerViewlet extends Viewlet {
6365
}
6466

6567
private addTreeView(): void {
66-
// Hide header (root node) by default
67-
const headerSize = 0;
68+
const headerSize = 0; // Hide header (root node) by default
6869

6970
this.view = this.instantiationService.createInstance(TreeExplorerView, this.viewletState, this.treeNodeProviderId, this.getActionRunner(), headerSize);
7071
this.view.render(this.viewletContainer.getHTMLElement(), Orientation.VERTICAL);
7172
}
7273

73-
private getTreeProviderName(viewletId: string): string {
74-
const tokens = viewletId.split('.');
75-
return tokens[tokens.length - 1];
74+
public focus(): void {
75+
super.focus();
76+
77+
if (this.view) {
78+
this.view.focusBody();
79+
}
80+
}
81+
82+
public shutdown(): void {
83+
if (this.view) {
84+
this.view.shutdown();
85+
}
86+
87+
super.shutdown();
7688
}
7789

7890
public dispose(): void {
79-
this.view = null;
91+
if (this.view) {
92+
this.view = null;
93+
this.view.dispose();
94+
}
95+
96+
super.dispose();
8097
}
8198
}

0 commit comments

Comments
 (0)