Skip to content

Commit 66c8331

Browse files
committed
Don't include placeholders as first or last line
1 parent ede8afd commit 66c8331

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/components/Snippet/index.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,18 @@ const Snippet: React.FC<SnippetProps> = ({
105105
}, Infinity);
106106

107107
lines.forEach((line, index) => {
108-
if (index > 0 && lines[index - 1] < line - 1) {
109-
includedContent.push(omitted_placeholder); // Add placeholder for omitted lines
110-
}
111-
112108
const rawLine = allLines[line - 1] || "";
113109
const trimmedLine =
114110
rawLine.trim().length > 0 ? rawLine.slice(minIndent) : rawLine;
111+
112+
if (index > 0 && lines[index - 1] < line - 1) {
113+
// Add placeholder for omitted lines only if within range
114+
includedContent.push(omitted_placeholder);
115+
}
116+
115117
includedContent.push(trimmedLine);
116118
});
117119

118-
// Add placeholder if lines at the end are omitted
119-
if (lines[lines.length - 1] < allLines.length) {
120-
includedContent.push(omitted_placeholder);
121-
}
122-
123120
return includedContent.join("\n");
124121
};
125122

0 commit comments

Comments
 (0)