This repository was archived by the owner on Apr 15, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,6 +327,18 @@ class InlineCoordsScan {
327327 this . y = ( side . top + side . bottom ) / 2
328328 return this . scan ( positions , getRects )
329329 }
330+ // Handle the case where closest matched a higher element on the
331+ // same line as an element below/above the coords
332+ if ( closestDx ) {
333+ if ( above && above . bottom > closestRect . top ) {
334+ this . y = above . bottom - 1
335+ return this . scan ( positions , getRects )
336+ }
337+ if ( below && below . top < closestRect . bottom ) {
338+ this . y = below . top + 1
339+ return this . scan ( positions , getRects )
340+ }
341+ }
330342 let ltr = ( bidi ? this . dirAt ( positions [ closestI ] , 1 ) : this . baseDir ) == Direction . LTR
331343 return {
332344 i : closestI ,
Original file line number Diff line number Diff line change @@ -243,6 +243,12 @@ describe("EditorView coords", () => {
243243 let c4 = cm . coordsAtPos ( 4 ) !
244244 ist ( cm . posAtCoords ( { x : c4 . left + 5 , y : c4 . bottom + 7 } ) , 9 )
245245 } )
246+
247+ it ( "can handle coordinates above small text in a non-uniform line" , ( ) => {
248+ let cm = tempView ( "abcdefgh" , [ deco ( Decoration . mark ( { attributes : { style : "font-size: 200%" } } ) . range ( 6 , 7 ) ) ] )
249+ let c4 = cm . coordsAtPos ( 4 ) !
250+ ist ( cm . posAtCoords ( { x : c4 . left , y : c4 . top - 4 } ) , 4 )
251+ } )
246252} )
247253
248254describe ( "coordsForChar" , ( ) => {
You can’t perform that action at this time.
0 commit comments