Open aikrahguzar opened 1 year ago
Another thing that is sub-optimal in my opinions is the similarity function used. It gives equal weight to all matching token no matter their length while I think giving more weight to longer words will produce better results. I am using,
(lambda (text source)
(if (if (consp text)
(member source text)
(equal text source))
(expt (length source) 2)
(- (expt (length source) 2))))
now and it has improved finding the exact word.
Describe the bug While writing latex I like to write a whole paragraph on a single line and use
visual-line-mode
instead of filling to some column which I find finicky. I notice that backward search often works for the beginning of a paragraph but fails if paragraph is long.What is the expected behaviour? Backward search finds the word I clicked on.
Additional context Digging into the source I found that it is due to how backward search uses
pdf-sync-backward-context-limit
. It is used1) To gather context words around the clicked area. 2) To limit the region of the line which is searched for finding the best alignment with context words. The region is of size
(* 6 pdf-sync-backward-context-limit)
so search doesn't find the correct word if it more than that many characters after the start of the line.So one solution is to increase the value of
pdf-sync-backward-context-limit
however as it is used for both 1 and 2 this causes massive slowdown.I think
pdf-sync-backward-context-limit
should be used only for the first part while the second part should used the whole line. The following diff accomplishes this,With this strategy it is possible to set
pdf-sync-backward-context-limit
to a smaller value than default. I have it set to16
and everything works fine and backward search find the correct location even if I click on a word which is repeated a lot during the paragraph but even with default value of64
and lines than are around1000
characters long, backward search is not noticeably slower than before this change.