@@ -437,27 +437,38 @@ That is supertype declaration or type declaration of let or var."
437437 '(" class" " extension" " enum" " struct" " protocol" " typealias"
438438 " associatedtype" ))))))
439439
440- (defun swift-mode:case-colon-p ()
441- " Return t if a colon at the cursor is the colon for case or default label."
442- (save-excursion
443- (member
444- ; ; This function can be confused by conditional operator.
445- ; ;
446- ; ;
447- ; ; switch foo {
448- ; ; case let x where x is Foo ?
449- ; ; a : // This function should return nil but it
450- ; ; // actually retuns t.
451- ; ; b: // This function should return t but it
452- ; ; // actually return nil.
453- ; ; let y = a ? b : c // This function returns nil correctly for this.
454- ; ; }
440+ (defvar swift-mode:in-recursive-call-of-case-colon-p nil
441+ " Non-nil if `case-colon-p' is being evaluated." )
455442
456- ; ; FIXME: mutual dependency
457- (swift-mode:token:text
458- (swift-mode:backward-sexps-until
459- '(implicit-\; \; { \( \[ " case" " default" " :" )))
460- '(" case" " default" ))))
443+ (defun swift-mode:case-colon-p ()
444+ " Return non-nil if the colon at the cursor follows case or default label.
445+
446+ Return nil otherwise."
447+ (if swift-mode:in-recursive-call-of-case-colon-p
448+ nil
449+ (save-excursion
450+ (setq swift-mode:in-recursive-call-of-case-colon-p t )
451+
452+ (unwind-protect
453+ (member
454+ ; ; FIXME:
455+ ; ; This function can be confused by conditional operator.
456+ ; ;
457+ ; ; switch foo {
458+ ; ; case let x where x is Foo ?
459+ ; ; a : // This function should return nil but it
460+ ; ; // actually retuns t.
461+ ; ; b: // This function should return t but it
462+ ; ; // actually return nil.
463+ ; ; let y = a ? b : c // This function returns nil correctly for this.
464+ ; ; }
465+
466+ ; ; FIXME: mutual dependency
467+ (swift-mode:token:text
468+ (swift-mode:backward-sexps-until
469+ '(implicit-\; \; { \( \[ " case" " default" " :" )))
470+ '(" case" " default" ))
471+ (setq swift-mode:in-recursive-call-of-case-colon-p nil )))))
461472
462473(defun swift-mode:anonyous-parameter-in-p ()
463474 " Return t if a 'in' token at the cursor is for anonymous function parameters."
0 commit comments