|
266 | 266 | (queue-callback |
267 | 267 | (λ () |
268 | 268 | (when searching-str |
269 | | - (define start-pos (get-focus-editor-start-position)) |
270 | | - (define (how-many-to-add k) |
271 | | - (if (search-result-compare <= (car k) start-pos) 1 0)) |
272 | | - (define count |
273 | | - (+ (if to-replace-highlight |
274 | | - (how-many-to-add to-replace-highlight) |
275 | | - 0) |
276 | | - (for/sum ([(k v) (in-hash search-bubble-table)]) |
277 | | - (how-many-to-add k)))) |
278 | | - (update-before-caret-search-hit-count count)) |
| 269 | + (update-before-caret-search-hit-count |
| 270 | + (calculate-before-caret-search-hit-count))) |
279 | 271 | (set! search-position-callback-running? #f)) |
280 | 272 | #f))) |
281 | 273 |
|
| 274 | + (define/private (calculate-before-caret-search-hit-count) |
| 275 | + (define start-pos (get-focus-editor-start-position)) |
| 276 | + (define (how-many-to-add k) |
| 277 | + (if (search-result-compare <= (car k) start-pos) 1 0)) |
| 278 | + (+ (if to-replace-highlight |
| 279 | + (how-many-to-add to-replace-highlight) |
| 280 | + 0) |
| 281 | + (for/sum ([(k v) (in-hash search-bubble-table)]) |
| 282 | + (how-many-to-add k)))) |
| 283 | + |
282 | 284 | (define/private (get-focus-editor-start-position) |
283 | 285 | (let loop ([txt this]) |
284 | 286 | (define focus (send txt get-focus-snip)) |
|
402 | 404 | (define new-search-bubbles '()) |
403 | 405 | (define new-replace-bubble #f) |
404 | 406 | (define first-hit (do-search 0)) |
405 | | - |
406 | | - (define-values (this-search-hit-count this-before-caret-search-hit-count) |
| 407 | + |
| 408 | + ;; TODO (maybe-queue-search-position-update) |
| 409 | + (define this-search-hit-count |
407 | 410 | (cond |
408 | 411 | [first-hit |
409 | 412 | (define sp (get-focus-editor-start-position)) |
410 | 413 | (let loop ([bubble-start first-hit] |
411 | | - [search-hit-count 0] |
412 | | - [before-caret-search-hit-count |
413 | | - (if (search-result-compare < first-hit sp) 1 0)]) |
| 414 | + [search-hit-count 0]) |
414 | 415 | (maybe-pause) |
415 | 416 | (define bubble-end (search-result+ bubble-start (string-length searching-str))) |
416 | 417 | (define bubble (cons bubble-start (string-length searching-str))) |
|
427 | 428 |
|
428 | 429 | (define next (do-search bubble-end)) |
429 | 430 |
|
430 | | - (define next-before-caret-search-hit-count |
431 | | - (if (and next (search-result-compare < next sp)) |
432 | | - (+ 1 before-caret-search-hit-count) |
433 | | - before-caret-search-hit-count)) |
434 | 431 | (cond |
435 | 432 | [next |
436 | 433 | ;; start a new one if there is another hit |
437 | | - (loop next |
438 | | - (+ search-hit-count 1) |
439 | | - next-before-caret-search-hit-count)] |
| 434 | + (loop next (+ search-hit-count 1))] |
440 | 435 | [else |
441 | | - (values (+ search-hit-count 1) |
442 | | - before-caret-search-hit-count)]))] |
443 | | - [else (values 0 0)])) |
| 436 | + (+ search-hit-count 1)]))] |
| 437 | + [else 0])) |
444 | 438 |
|
445 | 439 | (set! search-hit-count this-search-hit-count) |
446 | | - (set! before-caret-search-hit-count this-before-caret-search-hit-count) |
447 | 440 |
|
448 | 441 | (maybe-pause) |
449 | 442 |
|
|
460 | 453 | (highlight-hit search-bubble)]) |
461 | 454 | (maybe-pause)) |
462 | 455 |
|
463 | | - (update-yellow) |
| 456 | + (update-yellow) |
| 457 | + (set! before-caret-search-hit-count (calculate-before-caret-search-hit-count)) |
464 | 458 | (end-edit-sequence)] |
465 | 459 | [else |
466 | 460 | (begin-edit-sequence #t #f) |
|
0 commit comments