Simplify adding indentation

This commit is contained in:
Robert
2023-04-28 15:41:39 +01:00
parent 72c646c29b
commit 5ff5384551

View File

@@ -283,12 +283,9 @@ function generateMarkdownForPathResults(
language,
threadFlow.highlightedRegion,
);
// Indent the snippet to fit with the numbered list.
// The indentation is "n + 2" where the list number is an n-digit number.
const indentation = " ".repeat(listNumber.toString().length + 2);
pathLines.push(
...codeSnippet.map((line) =>
(" ".repeat(listNumber.toString().length + 2) + line).trimEnd(),
),
...codeSnippet.map((line) => indentation + line.trimEnd()),
);
}
}