branch: elpa/go-mode
commit 26493e3e9bea00453e1744364a6cb281fd4b167d
Author: Lowe Thiderman <[email protected]>
Commit: Dominik Honnef <[email protected]>

    Fix bug in go-goto-function if point is on a non-docstring
    
    Also make sure that the 'find next function downwards' functionality
    stops on the beginning of the word "func" and not after it.
---
 go-mode.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index d513064..0207131 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1586,11 +1586,12 @@ are below that anonymous function, go to the root 
function."
         (looking-at "^//"))
       ;; In case we are looking at the docstring, move on forward until we are
       ;; not anymore
-      ;; TODO(thiderman): This would behave incorrectly if point is
-      ;; inside a standalone block of comments that are not a docstring.
       (beginning-of-line)
       (while (looking-at "^//")
-        (forward-line 1)))
+        (forward-line 1))
+      ;; If we are still not looking at a function, retry by calling self 
again.
+      (when (not (looking-at "^func"))
+        (go-goto-function)))
 
      ((not (looking-at "^func"))
       ;; If we are not looking at the beginning of a function line, do a regexp
@@ -1600,7 +1601,8 @@ are below that anonymous function, go to the root 
function."
       ;; If nothing is found, assume that we are at the top of the file and
       ;; should search forward instead.
       (when (not (looking-at "func"))
-        (re-search-forward "\\<func\\>" nil t))
+        (re-search-forward "\\<func\\>" nil t)
+        (forward-word -1))
 
       ;; If we have landed at an anonymous function, it is possible that we
       ;; were not inside it but below it. If we were not inside it, we should

Reply via email to