Skip to content

Commit 04c8a62

Browse files
committed
Fix beginning-of-defun hanging at the beginning of buffer
Fixes #157. We would like to thank @dabrahams for reporting this, and @danielmartin for suggesting the cause.
1 parent 64dff57 commit 04c8a62

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

swift-mode-beginning-of-defun.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ and the region is not active."
9292
(setq result (swift-mode:beginning-of-defun-backward))
9393
(when (< (point) last-position)
9494
(setq arg (1- arg)))
95-
(when (< 0 arg)
96-
(swift-mode:backward-token-or-list))))
95+
(when (and (< 0 arg)
96+
(eq 'outside-of-buffer
97+
(swift-mode:token:type
98+
(swift-mode:backward-token-or-list))))
99+
(setq result nil))))
97100
;; Moving forward
98101
(setq result (swift-mode:beginning-of-defun-forward))
99102
(when (and result (< pos (point)))

0 commit comments

Comments
 (0)