@@ -68,7 +68,7 @@ export class BlockCursorPlugin {
6868 this . cursorLayer . className = "cm-cursorLayer cm-vimCursorLayer"
6969 this . cursorLayer . setAttribute ( "aria-hidden" , "true" )
7070 view . requestMeasure ( this . measureReq )
71- this . setBlinkRate ( )
71+ this . setBlinkRate ( )
7272 }
7373
7474 setBlinkRate ( ) {
@@ -78,11 +78,11 @@ export class BlockCursorPlugin {
7878 }
7979
8080 update ( update : ViewUpdate ) {
81- if ( update . selectionSet || update . geometryChanged || update . viewportChanged ) {
81+ if ( update . selectionSet || update . geometryChanged || update . viewportChanged ) {
8282 this . view . requestMeasure ( this . measureReq )
8383 this . cursorLayer . style . animationName = this . cursorLayer . style . animationName == "cm-blink" ? "cm-blink2" : "cm-blink"
84- }
85- if ( configChanged ( update ) ) this . setBlinkRate ( ) ;
84+ }
85+ if ( configChanged ( update ) ) this . setBlinkRate ( ) ;
8686 }
8787
8888 scheduleRedraw ( ) {
@@ -146,7 +146,7 @@ export const hideNativeSelection = Prec.highest(EditorView.theme(themeSpec))
146146function getBase ( view : EditorView ) {
147147 let rect = view . scrollDOM . getBoundingClientRect ( )
148148 let left = view . textDirection == Direction . LTR ? rect . left : rect . right - view . scrollDOM . clientWidth
149- return { left : left - view . scrollDOM . scrollLeft , top : rect . top - view . scrollDOM . scrollTop }
149+ return { left : left - view . scrollDOM . scrollLeft * view . scaleX , top : rect . top - view . scrollDOM . scrollTop * view . scaleY }
150150}
151151
152152function measureCursor ( cm : CodeMirror , view : EditorView , cursor : SelectionRange , primary : boolean ) : Piece | null {
@@ -179,6 +179,12 @@ function measureCursor(cm: CodeMirror, view: EditorView, cursor: SelectionRange,
179179 let base = getBase ( view ) ;
180180 let domAtPos = view . domAtPos ( head ) ;
181181 let node = domAtPos ? domAtPos . node : view . contentDOM ;
182+ if ( node instanceof Text && domAtPos . offset >= node . data . length ) {
183+ if ( node . parentElement ?. nextSibling ) {
184+ node = node . parentElement ?. nextSibling ;
185+ domAtPos = { node : node , offset : 0 } ;
186+ } ;
187+ }
182188 while ( domAtPos && domAtPos . node instanceof HTMLElement ) {
183189 node = domAtPos . node ;
184190 domAtPos = { node : domAtPos . node . childNodes [ domAtPos . offset ] , offset : 0 } ;
@@ -207,7 +213,7 @@ function measureCursor(cm: CodeMirror, view: EditorView, cursor: SelectionRange,
207213 letter += view . state . sliceDoc ( head + 1 , head + 2 ) ;
208214 }
209215 let h = ( pos . bottom - pos . top ) ;
210- return new Piece ( left - base . left , pos . top - base . top + h * ( 1 - hCoeff ) , h * hCoeff ,
216+ return new Piece ( ( left - base . left ) / view . scaleX , ( pos . top - base . top + h * ( 1 - hCoeff ) ) / view . scaleY , h * hCoeff / view . scaleY ,
211217 style . fontFamily , style . fontSize , style . fontWeight , style . color ,
212218 primary ? "cm-fat-cursor cm-cursor-primary" : "cm-fat-cursor cm-cursor-secondary" ,
213219 letter , hCoeff != 1 )
0 commit comments