From 377ece9c214f6abc93e8adbd128844c06308c1a8 Mon Sep 17 00:00:00 2001 From: Reodus <161498863+Reodus@users.noreply.github.com> Date: Thu, 3 Dec 2026 19:56:33 +0000 Subject: [PATCH 1/2] Initial plan From c8906711e6bde04736ec57a3819b9cb16a04219e Mon Sep 17 00:00:00 2001 From: Reodus <161498863+Reodus@users.noreply.github.com> Date: Thu, 3 Dec 2026 19:59:01 +0000 Subject: [PATCH 2/2] Extend editor navigation correction window Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- scripts/test-stability.ts | 19 ++++++++++++++++++- src/editor/navigation.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/test-stability.ts b/scripts/test-stability.ts index c768cb3..090486b 100644 --- a/scripts/test-stability.ts +++ b/scripts/test-stability.ts @@ -6,6 +6,7 @@ import { commentField } from '../src/editor/commentRanges.ts'; import { moveInTree, removeFromTree } from '../src/core/bookmarkTree.ts'; import { createWriteQueue } from '../src/core/writeQueue.ts'; import { startResize } from '../src/ui/resize.ts'; +import { revealEditorPosition } from '../src/editor/navigation.ts'; const c = { id:'c', from:{line:1,ch:0}, to:{line:1,ch:3}, quote:'AAA', body:'Review', created:'',updated:'',resolved:false,replies:[] }; const field=commentField(()=>[c]); @@ -43,4 +44,20 @@ for(const dir of ['ltr','rtl']){ handlers.get('lostpointercapture')!({pointerId:1,buttons:1}); handlers.get('pointermove')!({clientX:130,pointerId:1});handlers.get('pointerup')!({clientX:130,pointerId:1});assert.equal(width,dir==='ltr'?330:270);assert.equal(captured,false);assert.equal(handlers.size,0);assert.equal(raf,null); } -console.log('Stability: block moves + comment undo/redo, nested bookmarks, write ordering/retry and fast resize passed'); +let frames:Function[]=[],measurements=0,rendered=false; +Object.assign(globalThis,{requestAnimationFrame:(f:Function)=>(frames.push(f),frames.length),cancelAnimationFrame:()=>{}}); +const target=42,scroll={scrollTop:0,addEventListener(){},getBoundingClientRect:()=>({top:0,bottom:800})}; +const navigationView:any={ + state:{doc:{},selection:{main:{head:target}}}, + dom:{isConnected:true,addEventListener(){}}, + scrollDOM:scroll,documentTop:0,viewport:{from:0,to:10}, + dispatch(){},focus(){}, + coordsAtPos:()=>rendered?{top:400,bottom:420}:null, + lineBlockAt:()=>({top:1000,bottom:1200}), + requestMeasure(){if(++measurements===20){rendered=true;this.viewport={from:target,to:target};}}, +}; +revealEditorPosition(navigationView,target,'nearest'); +while(frames.length)frames.shift()!(); +assert.equal(rendered,true,'line navigation must keep correcting while delayed measurements materialize the target'); +assert.equal(measurements,20); +console.log('Stability: navigation correction, block moves + comment undo/redo, nested bookmarks, write ordering/retry and fast resize passed'); diff --git a/src/editor/navigation.ts b/src/editor/navigation.ts index 25cbda1..2b347f6 100644 --- a/src/editor/navigation.ts +++ b/src/editor/navigation.ts @@ -25,7 +25,7 @@ export function revealEditorPosition(view: EditorView, position: number, y: "nea view.dispatch({ selection: { anchor: position } }); view.focus(); - let framesLeft = 16; + let framesLeft = 120; let visibleFrames = 0; let center = y === "center"; const settle = () => {