diff --git a/collects/mred/private/snipfile.rkt b/collects/mred/private/snipfile.rkt index 9da20e4cb0..3749c5b5e4 100644 --- a/collects/mred/private/snipfile.rkt +++ b/collects/mred/private/snipfile.rkt @@ -106,7 +106,9 @@ (open-input-string (send text get-text start end) port-name) ;; It's all text, so the reading process is simple: (let ([start start]) - (when lock-while-reading? (send text lock #t)) + (when lock-while-reading? + (send text begin-edit-sequence) + (send text lock #t)) (let-values ([(pipe-r pipe-w) (make-pipe)]) (make-input-port/read-to-peek port-name @@ -119,7 +121,8 @@ (close-output-port pipe-w) (when lock-while-reading? (set! lock-while-reading? #f) - (send text lock #f)) + (send text lock #f) + (send text end-edit-sequence)) eof) (begin (write-string (send text get-text start (+ start n)) pipe-w) @@ -128,7 +131,8 @@ (when lock-while-reading? (when (eof-object? ans) (set! lock-while-reading? #f) - (send text lock #f))) + (send text lock #f) + (send text edit-edit-sequence))) ans)))) v))) (lambda (s skip general-peek) @@ -198,7 +202,8 @@ (when (eof-object? res) (when lock-while-reading? (set! lock-while-reading? #f) - (send text lock #f))) + (send text lock #f) + (send text end-edit-sequence))) res)) (lambda (s skip general-peek) (let ([v (peek-bytes-avail!* s skip #f pipe-r)]) @@ -206,7 +211,9 @@ (general-peek s skip) v))) close)]) - (when lock-while-reading? (send text lock #t)) + (when lock-while-reading? + (send text begin-edit-sequencce) + (send text lock #t)) (if (is-a? snip wx:string-snip%) ;; Special handling for initial snip string in ;; case it starts too early: diff --git a/collects/scribblings/gui/editor-funcs.scrbl b/collects/scribblings/gui/editor-funcs.scrbl index 24dd7864f6..ce249a4253 100644 --- a/collects/scribblings/gui/editor-funcs.scrbl +++ b/collects/scribblings/gui/editor-funcs.scrbl @@ -254,9 +254,15 @@ The result port must not be used if @racket[text-editor] changes in any @method[text% get-revision-number] method can be used to detect any of these changes. To help guard against such uses, if @racket[lock-while-reading?] argument is -a true value, then @racket[open-input-text-editor] will lock the @racket[text-editor] -before it returns and unlock it after it is safe to use the above methods. (In some -cases, it will not lock the editor at all, if using those methods are always safe.) +a true value, then @racket[open-input-text-editor] will +@method[editor<%> lock] the @racket[text-editor] and call +@method[editor<%> begin-edit-sequence] +before it returns and un@method[editor<%> lock] it and +call @method[editor<%> end-edit-sequence] +after it is safe to use the above methods. (In some +cases, it will not @method[editor<%> lock] the editor +or put it in an edit sequence at all, +if using those methods are always safe.) }