From 68b5d2abf85f716d8ccfb1c8c6a4392005bc9836 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 1 Mar 2011 15:14:36 -0600 Subject: [PATCH] adjust module lexer to handle the case of specials in the editor properly --- collects/syntax-color/module-lexer.rkt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/collects/syntax-color/module-lexer.rkt b/collects/syntax-color/module-lexer.rkt index bf21c26a2d..9d7a52d6c4 100644 --- a/collects/syntax-color/module-lexer.rkt +++ b/collects/syntax-color/module-lexer.rkt @@ -34,7 +34,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode). (cond [(or (eq? type 'comment) (eq? type 'white-space)) (define lexer-end (file-position lexer-port)) - (read-string lexer-end in) ;; sync ports + ;; sync ports + (for ([i (in-range 0 lexer-end)]) + (read-char-or-special in)) (values lexeme type data new-token-start new-token-end 0 'before-lang-line)] [else ;; look for #lang: @@ -44,7 +46,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode). (cond [(procedure? get-info) (define end-pos (file-position p)) - (read-string end-pos in) ;; sync ports + ;; sync ports + (for ([i (in-range 0 end-pos)]) + (read-char-or-special in)) ;; Produce language as first token: (values "#lang" @@ -60,7 +64,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode). v))) scheme-lexer))] [else - (read-string (file-position lexer-port) in) ;; sync ports + ;; sync ports + (for ([i (in-range 0 (file-position lexer-port))]) + (read-char-or-special in)) (if (and (eq? type 'other) (string? lexeme) ;; the read-language docs say that this is all it takes to commit to a #lang