From 8c6c1a0e9bfee79db27b6234a806df533b5bd7cb Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 1 Feb 2011 14:49:57 -0600 Subject: [PATCH] fix the get-token-range method in the case that the colorer's current region doesn't start at the begining of the buffer Please merge to the release branch --- collects/framework/private/color.rkt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/collects/framework/private/color.rkt b/collects/framework/private/color.rkt index 08ef4f5ecc..a1203f8fd1 100644 --- a/collects/framework/private/color.rkt +++ b/collects/framework/private/color.rkt @@ -817,16 +817,18 @@ added get-regions ;; Determines whether a position is a 'comment, 'string, etc. (define/public (classify-position position) - (define tokens (get-tokens-at-position 'classify-position position)) + (define-values (tokens ls) (get-tokens-at-position 'classify-position position)) (and tokens (let ([root-data (send tokens get-root-data)]) (and root-data (data-type root-data))))) (define/public (get-token-range position) - (define tokens (get-tokens-at-position 'get-token-range position)) - (values (and tokens (send tokens get-root-start-position)) - (and tokens (send tokens get-root-end-position)))) + (define-values (tokens ls) (get-tokens-at-position 'get-token-range position)) + (values (and tokens (+ (lexer-state-start-pos ls) + (send tokens get-root-start-position))) + (and tokens (+ (lexer-state-start-pos ls) + (send tokens get-root-end-position))))) (define/private (get-tokens-at-position who position) (when stopped? @@ -836,7 +838,7 @@ added get-regions (let ([tokens (lexer-state-tokens ls)]) (tokenize-to-pos ls position) (send tokens search! (- position (lexer-state-start-pos ls))) - tokens)))) + (values tokens ls))))) (define/private (tokenize-to-pos ls position) (when (and (not (lexer-state-up-to-date? ls))