This commit is contained in:
Johannes Rieken 2017-09-06 11:32:52 +02:00
parent edd70abb01
commit b7c5d6791c
2 changed files with 29 additions and 1 deletions

View file

@ -329,6 +329,23 @@ suite('window namespace tests', () => {
return Promise.all([a, b]);
});
test('Default value for showInput Box accepted even if fails validateInput, #33691', function () {
const result = window.showInputBox({
validateInput: (value: string) => {
if (!value || value.trim().length === 0) {
return 'Cannot set empty description';
}
return null;
}
}).then(value => {
assert.equal(value, undefined);
});
const exec = commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
return Promise.all([result, exec]);
});
test('editor, selection change kind', () => {
return workspace.openTextDocument(join(workspace.rootPath || '', './far.js')).then(doc => window.showTextDocument(doc)).then(editor => {

View file

@ -169,7 +169,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
: nls.localize('inputModeEntry', "Press 'Enter' to confirm your input or 'Escape' to cancel");
let currentPick = defaultMessage;
let currentValidation = TPromise.as(true);
let currentValidation: TPromise<boolean>;
let currentDecoration: Severity;
let lastValue: string;
@ -215,6 +215,17 @@ export class QuickOpenController extends Component implements IQuickOpenService
};
return new TPromise(init).then(item => {
if (!currentValidation) {
if (options.validateInput) {
currentValidation = options
.validateInput(lastValue === void 0 ? options.value : lastValue)
.then(message => !message);
} else {
currentValidation = TPromise.as(true);
}
}
return currentValidation.then(valid => {
if (valid && item) {
return lastValue === void 0 ? (options.value || '') : lastValue;