Skip to content

Commit

Permalink
generalize make-visible to accept start-pos and end-pos and use port-…
Browse files Browse the repository at this point in the history
…name-matches?

related to racket/htdp#231
  • Loading branch information
rfindler committed Oct 29, 2024
1 parent 073a2f9 commit d27a480
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drracket/drracket/private/unit.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3418,10 +3418,18 @@
(string=? (path->string (normal-case-path (normalize-path p1)))
(path->string (normal-case-path (normalize-path p2))))))

(define/override (make-visible filename)
(define/override (make-visible filename #:start-pos [start-pos #f] #:end-pos [end-pos start-pos])
(let ([tab (find-matching-tab filename)])
(when tab
(change-to-tab tab))))
(change-to-tab tab)
(when (and start-pos end-pos)
(define (set-the-position ed)
(when (send ed port-name-matches? filename)
(send (send ed get-canvas) focus)
(send ed set-caret-owner #f)
(send ed set-position start-pos end-pos)))
(set-the-position (send tab get-defs))
(set-the-position (send tab get-ints))))))

(define/public (find-matching-tab filename)
(define fn-path (if (string? filename)
Expand All @@ -3435,9 +3443,8 @@

(define/override (editing-this-file? filename)
(ormap (λ (tab)
(let ([fn (send (send tab get-defs) get-filename)])
(and fn
(pathname-equal? fn filename))))
(or (send (send tab get-defs) port-name-matches? filename)
(send (send tab get-ints) port-name-matches? filename)))
tabs))

(define/override (get-all-open-files)
Expand Down

0 comments on commit d27a480

Please sign in to comment.