fix: treat every list marker as a block boundary in full-block text

Review finding (pass 1): the full-block walk only recognized `- ` as
a list-item start, so in ordered (`1. `/`1) `) and `* `/`+ ` lists the
display text walked across neighboring items, even though each list
item is its own block in Obsidian. Bound both the upward and the
downward walk by a shared list-marker test, scoped to getBlockText so
the default-off single-line path is untouched.
This commit is contained in:
William Nurmi 2026-06-12 13:02:40 +03:00
parent 28b11fdc91
commit d100b15041

View file

@ -328,10 +328,19 @@ export default class EasyCopy extends Plugin {
}
/**
* block block
* `- `
* `- ` / `* ` / `+ ` / `1. ` / `1) ` block
* trim
*/
private isListItemStart(trimmedLine: string): boolean {
return /^(?:[-*+]|\d+[.)])\s/.test(trimmedLine);
}
/**
* block block
*
* ID extractBlockDisplayText
*
* block
* //退
* ID
*/
@ -339,7 +348,7 @@ export default class EasyCopy extends Plugin {
let start = cursorLine;
while (start > 0) {
const line = editor.getLine(start).trim();
if (line === '' || line.startsWith('- ') || line.startsWith('#')) {
if (line === '' || this.isListItemStart(line) || line.startsWith('#')) {
break; // 本行自己就是 block 的开头
}
const prev = editor.getLine(start - 1).trim();
@ -349,7 +358,11 @@ export default class EasyCopy extends Plugin {
start--;
}
let end = start;
while (end < editor.lineCount() - 1 && this.isContinuousText(editor.getLine(end + 1))) {
while (
end < editor.lineCount() - 1 &&
this.isContinuousText(editor.getLine(end + 1)) &&
!this.isListItemStart(editor.getLine(end + 1).trim())
) {
end++;
}
const lines: string[] = [];