fix all-string-snips? predicate

This commit is contained in:
Robby Findler 2015-07-25 16:44:22 -05:00
parent 1d22f69ba6
commit f91ec3df28
2 changed files with 20 additions and 6 deletions

View File

@ -4509,19 +4509,22 @@ designates the character that triggers autocompletion
[(is-a? s string-snip%) (loop (send s next))]
[else #f])))
(define/augment (after-insert start end)
(inner (void) after-insert start end)
(define/augment (after-insert start len)
(inner (void) after-insert start len)
(define end (+ start len))
(when (equal? all-string-snips-state #t)
(let loop ([s (find-snip start 'after-or-none)]
[i start])
(define init-i (box 0))
(define init-s (find-snip start 'after-or-none init-i))
(let loop ([s init-s]
[i (unbox init-i)])
(cond
[(not s) (void)]
[(not (< i end)) (void)]
[(is-a? s string-snip%)
(define size (send s get-count))
(loop (send s next) (+ i size))]
[else (set! all-string-snips-state #f)]))))
[else
(set! all-string-snips-state #f)]))))
(define/augment (on-delete start end)
(inner (void) on-delete start end)

View File

@ -344,6 +344,17 @@
(send t delete 2 4)
(send t all-string-snips?)))))
(test
'all-string-snips<%>.9
(λ (x) (equal? x #f))
(λ ()
(queue-sexp-to-mred
'(let ()
(define t (new (text:all-string-snips-mixin text%)))
(send t insert "abcdef\n")
(send t insert (new snip%) (send t last-position))
(send t all-string-snips?)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; print-to-dc