From d27a4804ab8c252afb06ce94ef77057bdac1d661 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 29 Oct 2024 15:44:15 -0500 Subject: [PATCH] generalize make-visible to accept start-pos and end-pos and use port-name-matches? related to racket/htdp#231 --- drracket/drracket/private/unit.rkt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drracket/drracket/private/unit.rkt b/drracket/drracket/private/unit.rkt index 7e49269a9..e25fa7578 100644 --- a/drracket/drracket/private/unit.rkt +++ b/drracket/drracket/private/unit.rkt @@ -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) @@ -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)