Skip to content

Commit

Permalink
Update for tests (#48116)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Apr 23, 2018
1 parent 32ebc3c commit f4b63ac
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
17 changes: 13 additions & 4 deletions extensions/vscode-api-tests/src/singlefolder-tests/window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,21 @@ suite('window namespace tests', () => {
}
return null;
}
}).then(value => {
assert.equal(value, undefined);
});

const exec = commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
return Promise.all([result, exec]);
const accept = commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
return Promise.race([
result.then(() => assert.ok(false)),
accept.then(() => assert.ok(false), err => assert.ok(err))
.then(() => new Promise(resolve => setTimeout(resolve, 10)))
])
.then(() => {
const close = commands.executeCommand('workbench.action.closeQuickOpen');
return Promise.all([result, close])
.then(([value]) => {
assert.equal(value, undefined);
});
});
});


Expand Down
3 changes: 3 additions & 0 deletions src/vs/platform/quickinput/common/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ export interface IQuickInputService {

pick<T extends IPickOpenEntry>(picks: TPromise<T[]>, options?: IPickOptions, token?: CancellationToken): TPromise<T[]>;
input(options?: IInputOptions, token?: CancellationToken): TPromise<string>;
focus(): void;
accept(): TPromise<void>;
cancel(): TPromise<void>;
}
27 changes: 22 additions & 5 deletions src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,16 @@ export class QuickInputService extends Component implements IQuickInputService {
if (this.controller) {
const resolved = this.controller.resolve(ok);
if (resolved) {
resolved
.then(() => this.container.style.display = 'none')
.then(null, onUnexpectedError);
return;
const result = resolved
.then(() => {
this.container.style.display = 'none';
});
result.then(null, onUnexpectedError);
return result;
}
}
this.container.style.display = 'none';
return TPromise.as(undefined);
}

pick<T extends IPickOpenEntry>(picks: TPromise<T[]>, options: IPickOptions = {}, token?: CancellationToken): TPromise<T[]> {
Expand Down Expand Up @@ -449,7 +452,21 @@ export class QuickInputService extends Component implements IQuickInputService {
return this.controller.result;
}

public layout(dimension: dom.Dimension): void {
focus() {
if (this.ui) {
this.ui.inputBox.setFocus();
}
}

accept() {
return this.close(true);
}

cancel() {
return this.close();
}

layout(dimension: dom.Dimension): void {
this.layoutDimensions = dimension;
this.updateLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { RemoveFromEditorHistoryAction } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
import { QuickOpenSelectNextAction, QuickOpenSelectPreviousAction, inQuickOpenContext, getQuickNavigateHandler, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, defaultQuickOpenContext, QUICKOPEN_ACTION_ID, QUICKOPEN_ACION_LABEL } from 'vs/workbench/browser/parts/quickopen/quickopen';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';

KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeQuickOpen',
Expand All @@ -21,6 +22,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: accessor => {
const quickOpenService = accessor.get(IQuickOpenService);
quickOpenService.close();
const quickInputService = accessor.get(IQuickInputService);
return quickInputService.cancel();
}
});

Expand All @@ -32,6 +35,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: accessor => {
const quickOpenService = accessor.get(IQuickOpenService);
quickOpenService.accept();
const quickInputService = accessor.get(IQuickInputService);
return quickInputService.accept();
}
});

Expand All @@ -43,6 +48,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: accessor => {
const quickOpenService = accessor.get(IQuickOpenService);
quickOpenService.focus();
const quickInputService = accessor.get(IQuickInputService);
quickInputService.focus();
}
});

Expand Down

0 comments on commit f4b63ac

Please sign in to comment.