From 0dbd3f1610a82be6759f17d93169c57c4aa79ea0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 4 May 2012 10:19:03 -0600 Subject: [PATCH] redex typesetting: make token splitter more tolerant Possibily the typesetting enginer should reject an ill-formed input, instead; I'm not sure what went wrong with the input. --- collects/redex/private/core-layout.rkt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/collects/redex/private/core-layout.rkt b/collects/redex/private/core-layout.rkt index 2cbe80ba66..326cd06a9d 100644 --- a/collects/redex/private/core-layout.rkt +++ b/collects/redex/private/core-layout.rkt @@ -594,17 +594,18 @@ (define (split-token offset tok new-token) (cond [(string-token? tok) + (define len (string-length (string-token-string tok))) (list (make-string-token (token-column tok) offset (substring (string-token-string tok) - 0 offset) + 0 (min len offset)) (string-token-style tok)) new-token (make-string-token (+ (token-column tok) offset) (- (token-span tok) offset) (substring (string-token-string tok) - offset - (string-length (string-token-string tok))) + (min offset len) + len) (string-token-style tok)))] [(pict-token? tok) (list new-token)]))