Skip to content

Commit

Permalink
Ignore extra empty client rects Safari provides at line wraps
Browse files Browse the repository at this point in the history
FIX: Fix an issue that caused `coordsForChar` to return the wrong rectangle for
characters after a line wrap in Safari.

Closes codemirror/dev#1275
  • Loading branch information
marijnh committed Oct 4, 2023
1 parent 88dafff commit f6b9927
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/docview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ export class DocView extends ContentView {
let end = findClusterBreak(child.text, off)
if (end == off) return null
let rects = textRange(child.dom as Text, off, end).getClientRects()
return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0]
for (let i = 0; i < rects.length; i++) {
let rect = rects[i]
if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right) return rect
}
return null
}

measureVisibleLineHeights(viewport: {from: number, to: number}) {
Expand Down

0 comments on commit f6b9927

Please sign in to comment.