Skip to content

Commit 8c421c2

Browse files
committed
fix for when the position doesn't have visible parens and has mismatched invisible parens
1 parent b1f128c commit 8c421c2

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

gui-lib/framework/private/color.rkt

+41-36
Original file line numberDiff line numberDiff line change
@@ -953,42 +953,47 @@ added get-regions
953953
(define invisible-paren-count (+ invisible-paren-opens invisible-paren-closes))
954954
(define-values (outermost-start outermost-end error-outermost)
955955
(send (lexer-state-parens ls) match-forward (- start (lexer-state-start-pos ls)) #:invisible invisible-paren-count))
956-
(let loop ([invisible-paren-count invisible-paren-count]
957-
[end-position outermost-end]
958-
[depth depth]
959-
[enclosing-highlight #f])
960-
(when (< depth (vector-length paren-colors))
961-
(define color (vector-ref paren-colors depth))
962-
(cond
963-
[(zero? invisible-paren-count)
964-
(define-values (start-inner end-inner error-inner)
965-
(send (lexer-state-parens ls) match-forward (- start (lexer-state-start-pos ls))))
966-
(when (or (not (zero? invisible-paren-opens))
967-
(not (zero? invisible-paren-closes))
968-
start-inner)
969-
(cond
970-
[start-inner
971-
(seq-loop (+ start-inner 1) (- end-inner 1) (+ depth 1))
972-
(seq-loop (+ end-inner 1) (- end-position 1) depth)]
973-
[else
974-
(seq-loop (+ outermost-start 1) (- outermost-end 1) depth)]))
975-
(unless error-inner
976-
(when (and start-inner end-inner)
977-
(highlight ls start-inner end-inner caret-pos color priority)))]
978-
[else
979-
(define-values (start-inner end-inner error-inner)
980-
(send (lexer-state-parens ls) match-forward
981-
(- start (lexer-state-start-pos ls))
982-
#:invisible invisible-paren-count))
983-
(unless error-inner
984-
(cond
985-
[(equal? enclosing-highlight (cons start-inner end-inner))
986-
(loop (- invisible-paren-count 1) end-inner depth enclosing-highlight)]
987-
[else
988-
(seq-loop (+ end-inner 1) (- end-position 1) depth)
989-
(loop (- invisible-paren-count 1) end-inner (+ depth 1) (cons start-inner end-inner))
990-
(highlight ls start-inner end-inner caret-pos color priority)]))])))
991-
outermost-end]
956+
(cond
957+
[(and outermost-start (not error-outermost))
958+
(let loop ([invisible-paren-count invisible-paren-count]
959+
[end-position outermost-end]
960+
[depth depth]
961+
[enclosing-highlight #f])
962+
(when (< depth (vector-length paren-colors))
963+
(define color (vector-ref paren-colors depth))
964+
(cond
965+
[(zero? invisible-paren-count)
966+
(define-values (start-inner end-inner error-inner)
967+
(send (lexer-state-parens ls) match-forward (- start (lexer-state-start-pos ls))))
968+
(when (or (not (zero? invisible-paren-opens))
969+
(not (zero? invisible-paren-closes))
970+
start-inner)
971+
(cond
972+
[start-inner
973+
(seq-loop (+ start-inner 1) (- end-inner 1) (+ depth 1))
974+
(seq-loop (+ end-inner 1) (- end-position 1) depth)]
975+
[else
976+
(seq-loop (+ outermost-start 1) (- outermost-end 1) depth)]))
977+
(unless error-inner
978+
(when (and start-inner end-inner)
979+
(highlight ls start-inner end-inner caret-pos color priority)))]
980+
[else
981+
(define-values (start-inner end-inner error-inner)
982+
(send (lexer-state-parens ls) match-forward
983+
(- start (lexer-state-start-pos ls))
984+
#:invisible invisible-paren-count))
985+
(unless error-inner
986+
(cond
987+
[(equal? enclosing-highlight (cons start-inner end-inner))
988+
(loop (- invisible-paren-count 1) end-inner depth enclosing-highlight)]
989+
[start-inner
990+
(seq-loop (+ end-inner 1) (- end-position 1) depth)
991+
(loop (- invisible-paren-count 1) end-inner (+ depth 1) (cons start-inner end-inner))
992+
(highlight ls start-inner end-inner caret-pos color priority)]
993+
[else
994+
(loop (- invisible-paren-count 1) end-inner (+ depth 1) enclosing-highlight)]))])))
995+
outermost-end]
996+
[else #f])]
992997
[else #f]))
993998

994999
(single-spot-loop orig-start 0)

0 commit comments

Comments
 (0)