make the search/replace button actually finish
all the internal work before returning from the button callback closes PR 14906
This commit is contained in:
parent
83eb701b2b
commit
927289cd8e
|
@ -528,6 +528,11 @@
|
|||
tracked via the @method[text% after-set-position] method.)
|
||||
}
|
||||
|
||||
@defmethod[(finish-pending-search-work) void?]{
|
||||
Finishes any pending work in computing and
|
||||
drawing the search bubbles.
|
||||
}
|
||||
|
||||
@defmethod[(get-search-bubbles)
|
||||
(listof (list/c (cons/c number? number?)
|
||||
(or/c 'normal-search-color
|
||||
|
|
|
@ -2469,18 +2469,19 @@
|
|||
(unhide-search #f)
|
||||
(send find-edit search searching-direction #t))
|
||||
|
||||
(define/public (search-replace)
|
||||
(let ([text-to-search (get-text-to-search)])
|
||||
(when text-to-search
|
||||
(let ([replacee-start (send text-to-search get-replace-search-hit)])
|
||||
(when replacee-start
|
||||
(let ([replacee-end (+ replacee-start (send find-edit last-position))])
|
||||
(send text-to-search begin-edit-sequence)
|
||||
(send text-to-search set-position replacee-end replacee-end)
|
||||
(send text-to-search delete replacee-start replacee-end)
|
||||
(copy-over replace-edit 0 (send replace-edit last-position) text-to-search replacee-start)
|
||||
(search 'forward)
|
||||
(send text-to-search end-edit-sequence)))))))
|
||||
(define/public (search-replace)
|
||||
(define text-to-search (get-text-to-search))
|
||||
(when text-to-search
|
||||
(define replacee-start (send text-to-search get-replace-search-hit))
|
||||
(when replacee-start
|
||||
(define replacee-end (+ replacee-start (send find-edit last-position)))
|
||||
(send text-to-search begin-edit-sequence)
|
||||
(send text-to-search set-position replacee-end replacee-end)
|
||||
(send text-to-search delete replacee-start replacee-end)
|
||||
(copy-over replace-edit 0 (send replace-edit last-position) text-to-search replacee-start)
|
||||
(search 'forward)
|
||||
(send text-to-search finish-pending-search-work)
|
||||
(send text-to-search end-edit-sequence))))
|
||||
|
||||
(define/private (copy-over src-txt src-start src-end dest-txt dest-pos)
|
||||
(send src-txt split-snip src-start)
|
||||
|
|
|
@ -1097,7 +1097,8 @@
|
|||
set-searching-state
|
||||
set-search-anchor
|
||||
get-search-bubbles
|
||||
get-search-hit-count))
|
||||
get-search-hit-count
|
||||
finish-pending-search-work))
|
||||
|
||||
(define normal-search-color (send the-color-database find-color "plum"))
|
||||
(define dark-search-color (send the-color-database find-color "mediumorchid"))
|
||||
|
@ -1343,14 +1344,27 @@
|
|||
(queue-callback (λ () (run-search)) #f)))
|
||||
|
||||
(define/private (run-search)
|
||||
(define done? (coroutine-run search-coroutine (void)))
|
||||
(cond
|
||||
[done?
|
||||
(set! search-coroutine #f)]
|
||||
[else
|
||||
(queue-callback
|
||||
(λ () (run-search))
|
||||
#f)]))
|
||||
;; there may be a call to (finish-pending-search-work) with a run-search
|
||||
;; pending so we check to see if that happened and do no work in that case.
|
||||
(when search-coroutine
|
||||
(define done? (coroutine-run search-coroutine (void)))
|
||||
(cond
|
||||
[done?
|
||||
(set! search-coroutine #f)]
|
||||
[else
|
||||
(queue-callback
|
||||
(λ () (run-search))
|
||||
#f)])))
|
||||
|
||||
(define/public (finish-pending-search-work)
|
||||
(when search-coroutine
|
||||
(let loop ()
|
||||
(define done? (coroutine-run search-coroutine (void)))
|
||||
(cond
|
||||
[done?
|
||||
(set! search-coroutine #f)]
|
||||
[else
|
||||
(loop)]))))
|
||||
|
||||
(define/private (create-search-coroutine notify-frame?)
|
||||
(coroutine
|
||||
|
|
Loading…
Reference in New Issue
Block a user