branch: elpa/swift-mode commit 04c8a621e9844ef3f7d53c41b046f71aadb1a9d2 Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
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. --- swift-mode-beginning-of-defun.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el index 26f276e..89263a2 100644 --- a/swift-mode-beginning-of-defun.el +++ b/swift-mode-beginning-of-defun.el @@ -92,8 +92,11 @@ and the region is not active." (setq result (swift-mode:beginning-of-defun-backward)) (when (< (point) last-position) (setq arg (1- arg))) - (when (< 0 arg) - (swift-mode:backward-token-or-list)))) + (when (and (< 0 arg) + (eq 'outside-of-buffer + (swift-mode:token:type + (swift-mode:backward-token-or-list)))) + (setq result nil)))) ;; Moving forward (setq result (swift-mode:beginning-of-defun-forward)) (when (and result (< pos (point)))