|
3419 | 3419 | (path->string (normal-case-path (normalize-path p2)))))) |
3420 | 3420 |
|
3421 | 3421 | (define/override (make-visible filename #:start-pos [start-pos #f] #:end-pos [end-pos start-pos]) |
3422 | | - (define tab |
3423 | | - (cond |
3424 | | - [(path-string? filename) |
3425 | | - (find-matching-tab filename)] |
3426 | | - [else |
3427 | | - ;; MM-unsaved-editor |
3428 | | - (and (symbol? filename) |
3429 | | - (for*/first ([tab (in-list tabs)] |
3430 | | - [ed (in-list (list (send tab get-defs) (send tab get-ints)))] |
3431 | | - #:when (send ed port-name-matches? filename)) |
3432 | | - tab))])) |
3433 | | - (when tab |
3434 | | - (change-to-tab tab) |
3435 | | - (when (and start-pos end-pos) |
3436 | | - (define (set-the-position ed) |
3437 | | - (when (send ed port-name-matches? filename) |
3438 | | - (send (send ed get-canvas) focus) |
3439 | | - (send ed set-caret-owner #f) |
3440 | | - (send ed set-position start-pos end-pos))) |
3441 | | - (set-the-position (send tab get-defs)) |
3442 | | - (set-the-position (send tab get-ints))))) |
| 3422 | + (match (find-matching-tab/which-editor filename) |
| 3423 | + [(cons tab ed) |
| 3424 | + (change-to-tab tab) |
| 3425 | + (when (and start-pos end-pos) |
| 3426 | + (send (send ed get-canvas) focus) |
| 3427 | + (send ed set-caret-owner #f) |
| 3428 | + (send ed set-position start-pos end-pos))] |
| 3429 | + [#f (void)])) |
3443 | 3430 |
|
3444 | 3431 | (define/public (find-matching-tab filename) |
3445 | | - (define fn-path (if (string? filename) |
3446 | | - (string->path filename) |
3447 | | - filename)) |
3448 | | - (for/or ([tab (in-list tabs)]) |
3449 | | - (define tab-filename (send (send tab get-defs) get-filename)) |
3450 | | - (and tab-filename |
3451 | | - (pathname-equal? fn-path tab-filename) |
3452 | | - tab))) |
3453 | | - |
| 3432 | + (match-define (cons tab ed) (find-matching-tab/which-editor filename)) |
| 3433 | + tab) |
| 3434 | + |
3454 | 3435 | (define/override (editing-this-file? filename) |
3455 | | - (ormap (λ (tab) |
3456 | | - (or (send (send tab get-defs) port-name-matches? filename) |
3457 | | - (send (send tab get-ints) port-name-matches? filename))) |
3458 | | - tabs)) |
| 3436 | + (and (find-matching-tab/which-editor filename) #t)) |
| 3437 | + |
| 3438 | + (define/private (find-matching-tab/which-editor filename) |
| 3439 | + (for/or ([tab (in-list tabs)]) |
| 3440 | + (define (try ed) |
| 3441 | + (and (send ed port-name-matches? filename) |
| 3442 | + (cons tab ed))) |
| 3443 | + (or (try (send tab get-defs)) |
| 3444 | + (try (send tab get-ints))))) |
3459 | 3445 |
|
3460 | 3446 | (define/override (get-all-open-files) |
3461 | 3447 | (filter |
|
0 commit comments