Skip to content

Commit 274cb9a

Browse files
Handle codeSnippet not being defined in markdown generation
1 parent 0394bd5 commit 274cb9a

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

extensions/ql-vscode/src/variant-analysis/markdown-generation.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,22 @@ function generateMarkdownForPathResults(
275275
threadFlow.highlightedRegion?.startLine,
276276
threadFlow.highlightedRegion?.endLine,
277277
);
278-
const codeSnippet = generateMarkdownForCodeSnippet(
279-
threadFlow.codeSnippet,
280-
language,
281-
threadFlow.highlightedRegion,
282-
);
283-
// Indent the snippet to fit with the numbered list.
284-
// The indentation is "n + 2" where the list number is an n-digit number.
285-
const codeSnippetIndented = codeSnippet.map((line) =>
286-
(" ".repeat(listNumber.toString().length + 2) + line).trimEnd(),
287-
);
288-
pathLines.push(`${listNumber}. ${link}`, ...codeSnippetIndented);
278+
pathLines.push(`${listNumber}. ${link}`);
279+
280+
if (threadFlow.codeSnippet) {
281+
const codeSnippet = generateMarkdownForCodeSnippet(
282+
threadFlow.codeSnippet,
283+
language,
284+
threadFlow.highlightedRegion,
285+
);
286+
// Indent the snippet to fit with the numbered list.
287+
// The indentation is "n + 2" where the list number is an n-digit number.
288+
pathLines.push(
289+
...codeSnippet.map((line) =>
290+
(" ".repeat(listNumber.toString().length + 2) + line).trimEnd(),
291+
),
292+
);
293+
}
289294
}
290295
lines.push(...buildExpandableMarkdownSection(title, pathLines));
291296
}

0 commit comments

Comments
 (0)