Skip to content

Commit f4d5417

Browse files
committed
fix(theme): ignore removed diff lines while copying code
1 parent 6bc46db commit f4d5417

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/client/app/composables/copyCode.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ export function useCopyCode() {
1414
}
1515

1616
const isShell = /language-(shellscript|shell|bash|sh|zsh)/.test(
17-
parent.classList.toString()
17+
parent.className
1818
)
1919

20-
let { innerText: text = '' } = sibling
20+
let text = ''
21+
22+
sibling
23+
.querySelectorAll('span.line:not(.diff.remove)')
24+
.forEach((node) => (text += (node.textContent || '') + '\n'))
25+
text = text.slice(0, -1)
2126

2227
if (isShell) {
2328
text = text.replace(/^ *(\$|>) /gm, '').trim()

0 commit comments

Comments
 (0)