Skip to content

Commit 8e6007c

Browse files
committed
fix broken source actions
1 parent 00abea2 commit 8e6007c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/extension.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,21 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
315315
if (token.isCancellationRequested) {
316316
return item;
317317
}
318-
const docChanges = result.edit.documentChanges;
319-
for (const editType of docChanges) {
320-
if ("textDocument" in editType) {
321-
for (const edit of editType.edits) {
322-
if ("snippet" in edit) {
323-
documentUris.push(editType.textDocument.uri);
324-
snippetEdits.push(new SnippetTextEdit(asRange((edit as any).range), new SnippetString((edit as any).snippet.value)));
318+
const docChanges = result.edit !== undefined ? result.edit.documentChanges : undefined;
319+
if (docChanges !== undefined) {
320+
for (const editType of docChanges) {
321+
if ("textDocument" in editType) {
322+
for (const edit of editType.edits) {
323+
if ("snippet" in edit) {
324+
documentUris.push(editType.textDocument.uri);
325+
snippetEdits.push(new SnippetTextEdit(asRange((edit as any).range), new SnippetString((edit as any).snippet.value)));
326+
}
325327
}
326328
}
327329
}
328330
}
329331
const codeAction = await client.protocol2CodeConverter.asCodeAction(result, token);
330-
const docEdits = codeAction.edit.entries();
332+
const docEdits = codeAction.edit !== undefined? codeAction.edit.entries() : [];
331333
const newWorkspaceEdit = new WorkspaceEdit();
332334
for (const doc of docEdits) {
333335
const uri = doc[0];

0 commit comments

Comments
 (0)