Skip to content

Commit 54e3784

Browse files
authored
Merge pull request #394 from PowerShell/kapilmb/fix-quick-fix
Allow quick fix to work in untitled documents
2 parents 7c4cafb + 1667eef commit 54e3784

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)