fix: wrong bounding coordinates for highlights

This should fix #10400.

After a multiline text selection in PDF, the first rectangle in sel-range is a incorrect "noise", not relevant to the selection range. The underlying cause is not clear to me. Note that it's a universal problem when doing mutliline highlights, even though most of the time it does not have any effect on user experience.   

This commit is a working hotfix. And very possibly there would be a better solution after looking into the update mechanism of the variable `sel-state` used here. But I have no enough experience to dive into this.
This commit is contained in:
e-zz
2023-10-28 05:00:05 +02:00
committed by Andelf
parent 43c8e1cb38
commit c55c25d3ca

View File

@@ -647,6 +647,9 @@
hl-fn #(when-let [page-info (pdf-utils/get-page-from-range sel-range)]
(when-let [sel-rects (pdf-utils/get-range-rects<-page-cnt sel-range (:page-el page-info))]
(let [page (int (:page-number page-info))
sel-rects (if (> (count sel-rects) 1)
(rest sel-rects)
sel-rects)
^js bounding (pdf-utils/get-bounding-rect sel-rects)
vw-pos {:bounding bounding :rects sel-rects :page page}
sc-pos (pdf-utils/vw-to-scaled-pos viewer vw-pos)]