Skip to content

Commit

Permalink
fix control-[ when in both automatic parens mode and fixup open paren…
Browse files Browse the repository at this point in the history
…s is turned on

closes #662
  • Loading branch information
rfindler committed Jan 23, 2024
1 parent 8fd03ce commit f7be366
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gui-lib/framework/private/racket.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1621,9 +1621,13 @@
(send text begin-edit-sequence)
(define start (send text get-start-position))
(define stop (send text get-end-position))
(send text insert char start stop)
(when (and closer (preferences:get 'framework:automatic-parens))
(send text insert closer (+ start 1) (+ start 1)))
(cond
[(and closer (preferences:get 'framework:automatic-parens))
(send text insert closer stop stop)
(send text insert char start start)
(send text set-position (+ start 1))]
[else
(send text insert char start stop)])
(send text end-edit-sequence)))

(define (map-pairs-keybinding-functions keymap opener closer
Expand Down
12 changes: 12 additions & 0 deletions gui-test/framework/tests/racket.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,18 @@
(test-parens-behavior/full (format "~a-~a" (string-append open close) (car s))
before-and-open "" after #\backspace `(,result ,result)))))

(let ()
(define fixup-open-parens (preferences:get 'framework:fixup-open-parens))
(define k (new key-event%
[key-code #\[]
[control-down #t]))
(preferences:set 'framework:fixup-open-parens #t)
(test-parens-behavior/full 'open-parens
"abc" "def" "ghi" ; editor state: before, selected, after
(list k) ; key(s) pressed
'(["abc[" "ghi"] ; result state sep by cursor, no auto-parens
["abc[" "def]ghi"])) ; result state with auto-parens
(preferences:set 'framework:fixup-open-parens fixup-open-parens))

#| for these, the key-event with meta-down doesn't seem to work... maybe a Mac OS
issue; and may cause problems with these tests on another platform? .nah. |#
Expand Down

0 comments on commit f7be366

Please sign in to comment.