Adjusts the prompt handling so that it submits expressions that signal
arbitrary read errors, but does not submit those that raise eof errors. closes PR 11126
This commit is contained in:
parent
a4b0c69ec2
commit
5de6ff2ada
|
@ -1327,10 +1327,13 @@
|
|||
@scheme[end] in @scheme[text] has at least one complete s-expression and
|
||||
there are no incomplete s-expressions. If
|
||||
@scheme[end] is @scheme[#f], it defaults to the last position of the
|
||||
@scheme[text].
|
||||
@scheme[text]. The designation ``complete'' is defined to be something that does not
|
||||
cause @racket[read] to raise a @racket[exn:fail:read:eof?] exception,
|
||||
so there may be all kinds of strange read-level (not to speak of parse level)
|
||||
errors in the expressions.
|
||||
|
||||
The implementation of this function creates a port with
|
||||
@scheme[open-input-text-editor] and then uses `read' to parse the
|
||||
@scheme[open-input-text-editor] and then uses @racket[read] to parse the
|
||||
range of the buffer.})
|
||||
|
||||
(proc-doc/names
|
||||
|
|
|
@ -44,13 +44,16 @@
|
|||
(let* ([end (or in-end (send text last-position))]
|
||||
[port (open-input-text-editor text start end)])
|
||||
(with-handlers ([exn:fail:read:eof? (λ (x) #f)]
|
||||
[exn:fail:read? (λ (x) #f)])
|
||||
[exn:fail:read? (λ (x) #t)])
|
||||
(let ([first (read port)])
|
||||
(and (not (eof-object? first))
|
||||
(let loop ()
|
||||
(let ([s (read port)])
|
||||
(or (eof-object? s)
|
||||
(loop))))))))))
|
||||
(cond
|
||||
[(eof-object? first) #f]
|
||||
[else
|
||||
(let loop ()
|
||||
(let ([s (read port)])
|
||||
(cond
|
||||
[(eof-object? s) #t]
|
||||
[else (loop)])))]))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
|
|
|
@ -21,10 +21,11 @@
|
|||
|
||||
(test-text-balanced? 0 "" 0 #f #f)
|
||||
(test-text-balanced? 1 " \n " 0 #f #f)
|
||||
(test-text-balanced? 2 "foo)" 0 #f #f)
|
||||
(test-text-balanced? 2 "foo)" 0 #f #t)
|
||||
(test-text-balanced? 3 "(foo" 0 #f #f)
|
||||
(test-text-balanced? 4 "(foo)" 0 #f #t)
|
||||
(test-text-balanced? 5 "(foo 'bar))" 0 #f #f)
|
||||
(test-text-balanced? 5 "(foo 'bar))" 0 #f #t)
|
||||
(test-text-balanced? 6 "(foo) bar ([buz])" 0 #f #t)
|
||||
(test-text-balanced? 7 "(foo]" 0 #f #f)
|
||||
(test-text-balanced? 7 "(foo]" 0 #f #t)
|
||||
(test-text-balanced? 8 "{foo} ((bar) [5.9])" 0 #f #t)
|
||||
(test-text-balanced? 9 "#(1 2 . 3)" 0 #f #t)
|
||||
|
|
Loading…
Reference in New Issue
Block a user