Clamp pos when storing scroll position (#30773)

GitOrigin-RevId: b381950e209c18a5fbba07604839b7c3eac90da8
This commit is contained in:
Alf Eaton
2026-01-15 13:25:18 +00:00
committed by Copybot
parent 9e9b5b22cf
commit 36432ffb5b

View File

@@ -155,7 +155,8 @@ const storeScrollPosition = (
) => {
const key = buildStorageKey(docId)
const data = customLocalStorage.getItem(key)
const firstVisibleLine = view.state.doc.lineAt(lineInfo.first.from).number
const pos = Math.min(lineInfo.first.from, view.state.doc.length)
const firstVisibleLine = view.state.doc.lineAt(pos).number
customLocalStorage.setItem(key, { ...data, firstVisibleLine })
}