mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Reposition all match text before find from view
If user scrolled and the match text position change, the `.top` property will not update automatically. Then the search from view will return the wrong match text because it make use of the old top properties. This commit reposition (and the top properties get updated) all match text before find the next match from the viewport.
This commit is contained in:
parent
cbafb8077e
commit
785b593bc4
1 changed files with 5 additions and 0 deletions
|
@ -233,6 +233,10 @@ export function removeHighlighting() {
|
|||
|
||||
export function focusHighlight(index) {
|
||||
lastHighlights[index].focus()
|
||||
repositionHighlight()
|
||||
}
|
||||
|
||||
export function repositionHighlight() {
|
||||
for (const node of lastHighlights) {
|
||||
node.updateRectsPosition()
|
||||
}
|
||||
|
@ -268,6 +272,7 @@ export async function jumpToNextMatch(n: number, searchFromView = false) {
|
|||
selected =
|
||||
(selected + n + lastHighlights.length) % lastHighlights.length
|
||||
} else {
|
||||
repositionHighlight()
|
||||
const length = lastHighlights.length
|
||||
const reverse = lastHighlights[length - 1].top < lastHighlights[0].top
|
||||
const negative = n < 0
|
||||
|
|
Loading…
Add table
Reference in a new issue