fix: getLineAtCursor bug with zero-position marks

fix: #605
This commit is contained in:
windingwind 2023-08-14 17:16:57 +08:00
parent fcd4e8e1c9
commit 2a6de3533e

View File

@ -163,15 +163,14 @@ function getRangeAtCursor(editor: Zotero.EditorInstance) {
function getLineAtCursor(editor: Zotero.EditorInstance) {
const position = getPositionAtCursor(editor);
const lastPos = getEditorCore(editor).view.state.tr.doc.content.size;
let i = 0;
let lastPos = 0;
let currentPos = getPositionAtLine(editor, 0);
while (currentPos !== lastPos) {
while (currentPos <= lastPos) {
if (position <= currentPos) {
break;
}
i += 1;
lastPos = currentPos;
currentPos = getPositionAtLine(editor, i);
}
return i;