Skip to content

Commit 0cc5639

Browse files
author
Kapil Borle
committed
Set file path in ApplyCodeActionEdits
EditorServices invokes PSScriptAnalyzer by passing `ScriptDefinition` paramter and not `Path` parameter. This results in null value of `ScriptPath` property of the returned diagnostic record which in turns leads to null value of `edit.file`. Therefore, we need to retrieve file path from the active editor.
1 parent 6c3ec2b commit 0cc5639

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/features/CodeActions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ export function registerCodeActionCommands(client: LanguageClient): void {
66
vscode.commands.registerCommand('PowerShell.ApplyCodeActionEdits', (edit: any) => {
77
console.log("Applying edits");
88
console.log(edit);
9-
9+
var editor = Window.activeTextEditor;
10+
var filePath = editor.document.fileName;
1011
var workspaceEdit = new vscode.WorkspaceEdit();
1112
workspaceEdit.set(
12-
vscode.Uri.file(edit.File),
13+
vscode.Uri.file(filePath),
1314
[
1415
new vscode.TextEdit(
1516
new vscode.Range(

0 commit comments

Comments
 (0)