Skip to content

Commit a377df1

Browse files
authored
Merge branch 'master' into statusBar
2 parents f6ae800 + e4e631a commit a377df1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/features/codeActionProvider.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
9090
return {
9191
title: codeAction.Name,
9292
command: this._commandId,
93-
arguments: [runRequest]
93+
arguments: [runRequest, token]
9494
};
9595
});
9696
}
@@ -99,10 +99,9 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
9999
}
100100
}
101101

102-
private async _runCodeAction(req: protocol.V2.RunCodeActionRequest): Promise<boolean | string | {}> {
103-
104-
return serverUtils.runCodeAction(this._server, req).then(response => {
102+
private async _runCodeAction(req: protocol.V2.RunCodeActionRequest, token: vscode.CancellationToken): Promise<boolean | string | {}> {
105103

104+
return serverUtils.runCodeAction(this._server, req).then(async response => {
106105
if (response && Array.isArray(response.Changes)) {
107106

108107
let edit = new vscode.WorkspaceEdit();
@@ -123,9 +122,9 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
123122
for (let change of response.Changes) {
124123
if (change.ModificationType == FileModificationType.Opened)
125124
{
126-
// The CodeAction requested that we open a file.
125+
// The CodeAction requested that we open a file.
127126
// Record that file name and keep processing CodeActions.
128-
// If a CodeAction requests that we open multiple files
127+
// If a CodeAction requests that we open multiple files
129128
// we only open the last one (what would it mean to open multiple files?)
130129
fileToOpen = vscode.Uri.file(change.FileName);
131130
}
@@ -135,7 +134,7 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
135134
let uri = vscode.Uri.file(change.FileName);
136135
if (renamedFiles.some(r => r == uri))
137136
{
138-
// This file got renamed. Omnisharp has already
137+
// This file got renamed. OmniSharp has already
139138
// persisted the new file with any applicable changes.
140139
continue;
141140
}
@@ -144,11 +143,14 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
144143
for (let textChange of change.Changes) {
145144
edits.push(vscode.TextEdit.replace(toRange2(textChange), textChange.NewText));
146145
}
147-
146+
148147
edit.set(uri, edits);
149148
}
150149
}
151150

151+
// Allow language middlewares to re-map its edits if necessary.
152+
edit = await this._languageMiddlewareFeature.remap("remapWorkspaceEdit", edit, token);
153+
152154
let applyEditPromise = vscode.workspace.applyEdit(edit);
153155

154156
// Unfortunately, the textEditor.Close() API has been deprecated
@@ -158,14 +160,14 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
158160
let next = applyEditPromise;
159161
if (renamedFiles.some(r => r.fsPath == vscode.window.activeTextEditor.document.uri.fsPath))
160162
{
161-
next = applyEditPromise.then(_ =>
163+
next = applyEditPromise.then(_ =>
162164
{
163165
return vscode.commands.executeCommand("workbench.action.closeActiveEditor");
164166
});
165167
}
166168

167169
return fileToOpen != null
168-
? next.then(_ =>
170+
? next.then(_ =>
169171
{
170172
return vscode.commands.executeCommand("vscode.open", fileToOpen);
171173
})

0 commit comments

Comments
 (0)