1
0
Fork 0

- fixed regression: searching in links window does not get stuck at the first occurence.

This commit is contained in:
cage 2021-06-16 19:08:41 +02:00
parent 68c250e03c
commit 34284f9a51
2 changed files with 17 additions and 7 deletions

View File

@ -289,15 +289,20 @@ this exact quantity would go beyond the length or rows or zero."
(handler-case (handler-case
(with-accessors ((row-selected-index row-selected-index)) object (with-accessors ((row-selected-index row-selected-index)) object
(let* ((scanner (create-scanner regex :case-insensitive-mode t)) (let* ((scanner (create-scanner regex :case-insensitive-mode t))
(selected-row (selected-row object))
(selected-text (normal-text selected-row))
(actual-row-starting (if (scan scanner selected-text)
(1+ row-selected-index)
row-selected-index))
(position-found (position-if (lambda (a) (position-found (position-if (lambda (a)
(if (selectedp a) (if (selectedp a)
(scan scanner (selected-text a)) (scan scanner (selected-text a))
(scan scanner (normal-text a)))) (scan scanner (normal-text a))))
(safe-subseq (rows object) (safe-subseq (rows object)
row-selected-index)))) actual-row-starting))))
(when position-found (when position-found
(unselect-all object) (unselect-all object)
(select-row object (+ row-selected-index position-found)) (select-row object (+ actual-row-starting position-found))
(when redraw (when redraw
(draw object)) (draw object))
position-found))) position-found)))

View File

@ -176,18 +176,23 @@
(defmethod search-row ((object open-gemini-document-link-window) regex &key (redraw t)) (defmethod search-row ((object open-gemini-document-link-window) regex &key (redraw t))
(handler-case (handler-case
(with-accessors ((row-selected-index row-selected-index)) object (with-accessors ((row-selected-index row-selected-index)
(let* ((saved-selected-index row-selected-index) (links links)) object
(scanner (create-scanner regex :case-insensitive-mode t)) (let* ((scanner (create-scanner regex :case-insensitive-mode t))
(selected-link (elt links row-selected-index))
(selected-text (gemini-parser:name selected-link))
(actual-row-starting (if (scan scanner selected-text)
(1+ row-selected-index)
row-selected-index))
(position-header (position-if (lambda (a) (position-header (position-if (lambda (a)
(scan scanner (scan scanner
(gemini-parser:name a))) (gemini-parser:name a)))
(safe-subseq (links object) (safe-subseq (links object)
row-selected-index)))) actual-row-starting))))
(call-next-method) ; search in urls (call-next-method) ; search in urls
(when position-header ; but if an header has been found, it wins (when position-header ; but if an header has been found, it wins
(unselect-all object) (unselect-all object)
(select-row object (+ saved-selected-index position-header)) (select-row object (+ actual-row-starting position-header))
(when redraw (when redraw
(draw object))))) (draw object)))))
(error () (error ()