Skip to content

Commit 69523a0

Browse files
committed
try a little bit different organization of the helper functions
1 parent 7c16fd3 commit 69523a0

File tree

1 file changed

+20
-34
lines changed

1 file changed

+20
-34
lines changed

drracket/drracket/private/unit.rkt

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,43 +3419,29 @@
34193419
(path->string (normal-case-path (normalize-path p2))))))
34203420

34213421
(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)]))
34433430

34443431
(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+
34543435
(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)))))
34593445

34603446
(define/override (get-all-open-files)
34613447
(filter

0 commit comments

Comments
 (0)