0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 18:48:39 +00:00

pagemap rename

This commit is contained in:
Víctor Losada Hernández
2026-04-14 00:06:49 +02:00
parent 9e72fad9e4
commit 62814e5d67
+4 -5
View File
@@ -147,8 +147,7 @@ const CodeEditor = forwardRef(
const docsRef = useRef({}); const docsRef = useRef({});
const prevTabRef = useRef(tab); const prevTabRef = useRef(tab);
// page map const pageMap = useRef([]);
const pageBreaksRef = useRef([]);
const recomputePages = (doc)=>{ const recomputePages = (doc)=>{
const pages = [0]; const pages = [0];
@@ -162,11 +161,11 @@ const CodeEditor = forwardRef(
offset += line.length + 1; offset += line.length + 1;
} }
pageBreaksRef.current = pages; pageMap.current = pages;
}; };
const findPageFromPos = (pos)=>{ const findPageFromPos = (pos)=>{
const pages = pageBreaksRef.current; const pages = pageMap.current;
let page = 1; let page = 1;
for (let i = 1; i < pages.length; i++) { for (let i = 1; i < pages.length; i++) {
@@ -360,7 +359,7 @@ const CodeEditor = forwardRef(
const view = viewRef.current; const view = viewRef.current;
if(!view) return; if(!view) return;
const pos = pageBreaksRef.current[pageNumber - 1] ?? 0; const pos = pageMap.current[pageNumber - 1] ?? 0;
view.dispatch({ view.dispatch({
selection : { anchor: pos }, selection : { anchor: pos },