Allow applyCodeActionCommand to take an array (#19870)

* Allow applyCodeActionCommand to take an array

* Use this.host.newLine
This commit is contained in:
Andy
2017-11-09 13:17:47 -08:00
committed by GitHub
parent 65a191fa2b
commit b94940525b
7 changed files with 22 additions and 4 deletions

View File

@@ -586,6 +586,7 @@ namespace ts.server.protocol {
}
export interface ApplyCodeActionCommandRequestArgs extends FileRequestArgs {
/** May also be an array of commands. */
command: {};
}

View File

@@ -1571,9 +1571,12 @@ namespace ts.server {
private applyCodeActionCommand(commandName: string, requestSeq: number, args: protocol.ApplyCodeActionCommandRequestArgs): void {
const { file, project } = this.getFileAndProject(args);
const output = (success: boolean, message: string) => this.doOutput({}, commandName, requestSeq, success, message);
const command = args.command as CodeActionCommand; // They should be sending back the command we sent them.
const command = args.command as CodeActionCommand | CodeActionCommand[]; // They should be sending back the command we sent them.
project.getLanguageService().applyCodeActionCommand(file, command).then(
({ successMessage }) => { output(/*success*/ true, successMessage); },
result => {
output(/*success*/ true, isArray(result) ? result.map(res => res.successMessage).join(`${this.host.newLine}${this.host.newLine}`) : result.successMessage);
},
error => { output(/*success*/ false, error); });
}