🐛 choice service needs cancelId argument

fixes #25226
This commit is contained in:
Joao Moreno
2017-04-27 09:24:57 +02:00
parent d8a1d8b8a7
commit b2b251c786
12 changed files with 25 additions and 23 deletions

View File

@@ -69,25 +69,27 @@ export class MainThreadMessageService extends MainThreadMessageServiceShape {
}
private showModalMessage(severity: Severity, message: string, commands: { title: string; isCloseAffordance: boolean; handle: number; }[]): Thenable<number> {
let hasCloseAffordance = false;
let cancelId: number | undefined = void 0;
const options = commands.map((command, index) => {
if (command.isCloseAffordance === true) {
hasCloseAffordance = true;
cancelId = index;
}
return command.title;
});
if (!hasCloseAffordance) {
if (cancelId === void 0) {
if (options.length > 0) {
options.push(nls.localize('cancel', "Cancel"));
} else {
options.push(nls.localize('ok', "OK"));
}
cancelId = options.length - 1;
}
return this._choiceService.choose(severity, message, options, true)
return this._choiceService.choose(severity, message, options, cancelId, true)
.then(result => result === commands.length ? undefined : commands[result].handle);
}
}