From c55c25d3caeb3036f44e9eba6793cacb4f3284cb Mon Sep 17 00:00:00 2001 From: e-zz <37920155+e-zz@users.noreply.github.com> Date: Sat, 28 Oct 2023 05:00:05 +0200 Subject: [PATCH] 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. --- src/main/frontend/extensions/pdf/core.cljs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/frontend/extensions/pdf/core.cljs b/src/main/frontend/extensions/pdf/core.cljs index 217bc2b736..9563c088e9 100644 --- a/src/main/frontend/extensions/pdf/core.cljs +++ b/src/main/frontend/extensions/pdf/core.cljs @@ -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)]