|
2 | 2 | // Licensed under the MIT License. |
3 | 3 |
|
4 | 4 | import vscode = require("vscode"); |
5 | | -import Window = vscode.window; |
6 | 5 | import { ILogger } from "../logging"; |
7 | 6 |
|
8 | 7 | export class CodeActionsFeature implements vscode.Disposable { |
9 | | - private applyEditsCommand: vscode.Disposable; |
10 | 8 | private showDocumentationCommand: vscode.Disposable; |
11 | 9 |
|
12 | 10 | constructor(private log: ILogger) { |
13 | | - // TODO: What type is `edit`, what uses this, and is it working? |
14 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
15 | | - this.applyEditsCommand = vscode.commands.registerCommand("PowerShell.ApplyCodeActionEdits", async (edit: any) => { |
16 | | - await Window.activeTextEditor?.edit((editBuilder) => { |
17 | | - editBuilder.replace( |
18 | | - new vscode.Range( |
19 | | - edit.StartLineNumber - 1, |
20 | | - edit.StartColumnNumber - 1, |
21 | | - edit.EndLineNumber - 1, |
22 | | - edit.EndColumnNumber - 1), |
23 | | - edit.Text); |
24 | | - }); |
25 | | - }); |
26 | | - |
| 11 | + // NOTE: While not exposed to the user via package.json, this is |
| 12 | + // required as the server's code action sends across a command name. |
| 13 | + // |
| 14 | + // TODO: In the far future with LSP 3.19 the server can just set a URL |
| 15 | + // and this can go away. See https://github.com/microsoft/language-server-protocol/issues/1548 |
27 | 16 | this.showDocumentationCommand = |
28 | 17 | vscode.commands.registerCommand("PowerShell.ShowCodeActionDocumentation", async (ruleName: string) => { |
29 | 18 | await this.showRuleDocumentation(ruleName); |
30 | 19 | }); |
31 | 20 | } |
32 | 21 |
|
33 | 22 | public dispose(): void { |
34 | | - this.applyEditsCommand.dispose(); |
35 | 23 | this.showDocumentationCommand.dispose(); |
36 | 24 | } |
37 | 25 |
|
|
0 commit comments