Skip to content

Commit

Permalink
end streaks in do-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
rfindler committed Jan 19, 2019
1 parent 1094b6d commit 2b75eb3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions gui-lib/mred/private/wxme/text.rkt
Expand Up @@ -1873,6 +1873,7 @@
(values (sub1 start) start #t))
(values start end (and (= start startpos)
(= end endpos))))])
(end-streaks '(delayed))
(unless (or (start . >= . end)
(start . < . 0)
(start . >= . len))
Expand Down
47 changes: 47 additions & 0 deletions gui-test/tests/gracket/wxme.rkt
Expand Up @@ -619,6 +619,53 @@
(send t insert (make-string 1024 #\a))
(expect (send t last-position) 2048)

;; ----------------------------------------
;; test how the insertion point moves during deletions

(let ()

(define lines
(list
"(define (f x)\n"
" (+ x x)\n"
" (+ x x))\n"))

(define init-position
(+ (string-length (list-ref lines 0))
(string-length (list-ref lines 1))
-1 ;; before the newline
))

(define second-position
(+ (string-length (list-ref lines 0))
2 ;; after the leading space
))

(let ()
(define t (new text%))

(send t insert (apply string-append lines))
(send t set-position init-position)
(for ([_ (in-range (- init-position second-position))])
(send t move-position 'left #t))
(send t delete 16 23)
(send t move-position 'home #t)
(expect (send t get-start-position) 0)
(expect (send t get-end-position) 16))

(let ()
(define t (new text%))

(send t insert (apply string-append lines))
(send t set-position init-position)
(for ([_ (in-range (- init-position second-position))])
(send t move-position 'left #f))
(send t delete 16 23)
(send t move-position 'home #t)
(expect (send t get-start-position) 0)
(expect (send t get-end-position) 16)))


;; ----------------------------------------
;; Moving and word boundaries

Expand Down

0 comments on commit 2b75eb3

Please sign in to comment.