summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-05-08 13:14:14 +0000
committerAlan Mackenzie <acm@muc.de>2022-05-08 13:16:46 +0000
commitf93c94996c7a8062878e1b7e0e7dba74bf5b98cd (patch)
treeed973ae12529a36317bbbc49eb7ae62ab73f6827 /lisp
parentc7bd76a3f02d0a426c85035fd37b0d1a8b6ea5d9 (diff)
downloademacs-f93c94996c7a8062878e1b7e0e7dba74bf5b98cd.tar.gz
emacs-f93c94996c7a8062878e1b7e0e7dba74bf5b98cd.tar.bz2
emacs-f93c94996c7a8062878e1b7e0e7dba74bf5b98cd.zip
CC Mode: Fix bug in c-parse-state. Fixes bug #55181.
* lisp/progmodes/cc-engine.el (c-state-cache-lower-good-pos): When in a literal, return the start of that literal as a "good pos", not the parameter POS.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/cc-engine.el6
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index b2fa9e06911..ae68bf989a7 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -3422,7 +3422,9 @@ initializing CC Mode. Currently (2020-06) these are `js-mode' and
;; Return a good pos (in the sense of `c-state-cache-good-pos') at the
;; lowest[*] position between POS and HERE which is syntactically equivalent
;; to HERE. This position may be HERE itself. POS is before HERE in the
- ;; buffer.
+ ;; buffer. If POS and HERE are both in the same literal, return the start
+ ;; of the literal. STATE is the parsing state at POS.
+ ;;
;; [*] We don't actually always determine this exact position, since this
;; would require a disproportionate amount of work, given that this function
;; deals only with a corner condition, and POS and HERE are typically on
@@ -3438,7 +3440,7 @@ initializing CC Mode. Currently (2020-06) these are `js-mode' and
(setq pos (point)
state s)))
(if (eq (point) here) ; HERE is in the same literal as POS
- pos
+ (nth 8 state) ; A valid good pos cannot be in a literal.
(setq s (parse-partial-sexp pos here (1+ (car state)) nil state nil))
(cond
((> (car s) (car state)) ; Moved into a paren between POS and HERE