@@ -653,7 +653,7 @@ Also used for regexes."
653
653
; ; After "in" for anonymous function parameters
654
654
((eq previous-type 'anonymous-function-parameter-in )
655
655
(goto-char (swift-mode:token:start previous-token))
656
- (swift-mode:backward-sexps-until '({) )
656
+ (swift-mode:backward-sexps-until-open-curly-brace )
657
657
(swift-mode:calculate-indent-after-open-curly-brace
658
658
swift-mode:basic-offset))
659
659
@@ -1353,6 +1353,24 @@ is the symbol `any', it matches all tokens."
1353
1353
(setq text (swift-mode:token:text parent)))
1354
1354
parent))
1355
1355
1356
+ (defun swift-mode:backward-sexps-until-open-curly-brace ()
1357
+ " Backward sexps until an open curly brace appears.
1358
+ Return the brace token.
1359
+ When this function returns, the cursor is at the start of the token.
1360
+
1361
+ If there is no open curly braces, return `outside-of-buffer' token.
1362
+
1363
+ This is optimized version of (swift-mode:backward-sexps-until '({}))."
1364
+ (let* ((parent-position (nth 1 (syntax-ppss ))))
1365
+ (while (and parent-position
1366
+ (and (goto-char parent-position)
1367
+ (not (eq (char-after ) ?{ ))))
1368
+ (setq parent-position (nth 1 (syntax-ppss ))))
1369
+ (if (eq (char-after ) ?{ )
1370
+ (save-excursion (swift-mode:forward-token))
1371
+ (goto-char (point-min ))
1372
+ (swift-mode:backward-token))))
1373
+
1356
1374
(defun swift-mode:align-with-next-token (parent &optional offset )
1357
1375
" Return indentation with the PARENT and OFFSET."
1358
1376
(let ((parent-end (swift-mode:token:end parent)))
0 commit comments