From f0a85b7be2b924bcba508ba679db6e1d18d92437 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 31 Oct 2012 09:42:49 -0500 Subject: [PATCH] fix a bug in the colorer refactoring As it turns out, changing the color (via change-style) can somtimes split snips, which can change the revision number, which means that the open port into the editor is no longer valid. Since this doesn't seem to happen very much when editing in DrRacket, we just detect this situation and give up on this colorer's port, and hopefully it actually doesn't happen much (the place it happened that let me notice this was when inserting an image via a menu in the drracket test suites) original commit: 226a7140b5784531103e10338785249a37aac677 --- collects/framework/private/color.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collects/framework/private/color.rkt b/collects/framework/private/color.rkt index fd576783..58d84c51 100644 --- a/collects/framework/private/color.rkt +++ b/collects/framework/private/color.rkt @@ -310,6 +310,7 @@ added get-regions (lexer-state-end-pos re-tokenize-ls-argument) (λ (x) #f))) (port-count-lines! re-tokenize-in-argument) + (set! rev (get-revision-number)) (continue-re-tokenize start-time #t)])) (define re-tokenize-lses #f) @@ -319,7 +320,8 @@ added get-regions (define re-tokenize-lexer-mode-argument #f) (define/private (continue-re-tokenize start-time did-something?) (cond - [(and did-something? ((+ start-time 20) . <= . (current-inexact-milliseconds))) + [(or (not (= rev (get-revision-number))) + (and did-something? ((+ start-time 20) . <= . (current-inexact-milliseconds)))) #f] [else ;(define-values (_line1 _col1 pos-before) (port-next-location in)) @@ -512,7 +514,6 @@ added get-regions [(and colorer-pending? (= rev (get-revision-number))) (continue-re-tokenize (current-inexact-milliseconds) #f)] [else - (set! rev (get-revision-number)) (start-re-tokenize (current-inexact-milliseconds))])) (cond [finished?