From 25f92f8e9ead040b602dffc0066bd85df8e1869a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 2 Feb 2013 19:34:20 -0600 Subject: [PATCH] fix a problem with the way that check syntax's interval map tracks information about the program --- collects/drracket/private/syncheck/gui.rkt | 17 ++++++++--------- collects/tests/drracket/syncheck-test.rkt | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/collects/drracket/private/syncheck/gui.rkt b/collects/drracket/private/syncheck/gui.rkt index 9e870f615e..29591a0e78 100644 --- a/collects/drracket/private/syncheck/gui.rkt +++ b/collects/drracket/private/syncheck/gui.rkt @@ -811,11 +811,12 @@ If the namespace does not, they are colored the unbound color. ;; the last test in the above and is because some syntax objects ;; appear to be from the original source, but can have bogus information. - ;; Use (add1 end) below, because interval-maps use half-open intervals - ;; ie, [start, end] = [start, end+1) + ;; interval-maps use half-open intervals which works out well for positions + ;; in the editor, since the interval [0,3) covers the characters just after + ;; positions 0, 1, and 2, but not the character at position 3 (positions are + ;; between characters) (cond [use-key? - (interval-map-update*! arrow-record - start (add1 end) + (interval-map-update*! arrow-record start end (lambda (old) (if (for/or ([x (in-list old)]) (and (pair? x) (car x) (eq? (car x) key))) @@ -823,9 +824,8 @@ If the namespace does not, they are colored the unbound color. (cons (cons key to-add) old))) null)] [else - (interval-map-cons*! arrow-record - start (add1 end) - to-add null)]))) + (interval-map-cons*! + arrow-record start end to-add null)]))) (define/private (add-identifier-to-range text/start/ends name-dup?) (define id-set (apply set text/start/ends)) @@ -835,8 +835,7 @@ If the namespace does not, they are colored the unbound color. (define arrow-record (get-arrow-record arrow-records (list-ref text/start/span 0))) (define start (list-ref text/start/span 1)) (define end (list-ref text/start/span 2)) - (interval-map-update*! arrow-record - start (add1 end) + (interval-map-update*! arrow-record start end (lambda (curr-val) (define this-uf-set (for/or ([thing (in-list curr-val)]) diff --git a/collects/tests/drracket/syncheck-test.rkt b/collects/tests/drracket/syncheck-test.rkt index 5337a51a63..a56c80be55 100644 --- a/collects/tests/drracket/syncheck-test.rkt +++ b/collects/tests/drracket/syncheck-test.rkt @@ -1149,7 +1149,20 @@ " x x x x x x x x x x x x x x x x x x x x x x x x\n" " x x x x x x x x x x x x x x x x x x x x x x x x\n" " x x x x x x x x x x x x x x x x x x x x x x x x)\n")) - )) + (build-rename-test + (string-append + "#lang racket\n" + "(let ([x 1])\n" + " x`1\n" + " `2)\n") + 20 + "x" + "y" + (string-append + "#lang racket\n" + "(let ([y 1])\n" + " y`1\n" + " `2)\n")))) (define (main)