Skip to content

Commit 1667eef

Browse files
author
Kapil Borle
committed
Allow quick fix to work in untitled documents
In the previous iteration of this feature, the edits can be applied to files open in a workspace. This commit removes that restriction.
1 parent 7c4cafb commit 1667eef

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/features/CodeActions.ts

+9-15
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,15 @@ export class CodeActionsFeature implements IFeature {
99

1010
constructor() {
1111
this.command = vscode.commands.registerCommand('PowerShell.ApplyCodeActionEdits', (edit: any) => {
12-
var editor = Window.activeTextEditor;
13-
var filePath = editor.document.fileName;
14-
var workspaceEdit = new vscode.WorkspaceEdit();
15-
workspaceEdit.set(
16-
vscode.Uri.file(filePath),
17-
[
18-
new vscode.TextEdit(
19-
new vscode.Range(
20-
edit.StartLineNumber - 1,
21-
edit.StartColumnNumber - 1,
22-
edit.EndLineNumber - 1,
23-
edit.EndColumnNumber - 1),
24-
edit.Text)
25-
]);
26-
vscode.workspace.applyEdit(workspaceEdit);
12+
Window.activeTextEditor.edit((editBuilder) => {
13+
editBuilder.replace(
14+
new vscode.Range(
15+
edit.StartLineNumber - 1,
16+
edit.StartColumnNumber - 1,
17+
edit.EndLineNumber - 1,
18+
edit.EndColumnNumber - 1),
19+
edit.Text);
20+
});
2721
});
2822
}
2923

0 commit comments

Comments
 (0)