Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/components/Snippet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,18 @@ const Snippet: React.FC<SnippetProps> = ({
}, Infinity);

lines.forEach((line, index) => {
if (index > 0 && lines[index - 1] < line - 1) {
includedContent.push(omitted_placeholder); // Add placeholder for omitted lines
}

const rawLine = allLines[line - 1] || "";
const trimmedLine =
rawLine.trim().length > 0 ? rawLine.slice(minIndent) : rawLine;

if (index > 0 && lines[index - 1] < line - 1) {
// Add placeholder for omitted lines only if within range
includedContent.push(omitted_placeholder);
}

includedContent.push(trimmedLine);
});

// Add placeholder if lines at the end are omitted
if (lines[lines.length - 1] < allLines.length) {
includedContent.push(omitted_placeholder);
}

return includedContent.join("\n");
};

Expand Down