branch: elpa/go-mode
commit a6717a1bd9b5cdbec861f77e577301260c8d257b
Author: Will <[email protected]>
Commit: Dominik Honnef <[email protected]>

    Fix filename replacement in gofmt error buffer
    
    goimport's new -srcdir option rewrites the directory but not the
    filename causing the regexp search & replace to fail
    
    Closes: gh-129
    Closes: gh-130 [via git-merge-pr]
---
 AUTHORS    | 1 +
 go-mode.el | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 75f1cc9..eefc714 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -32,4 +32,5 @@ Scott Lawrence <[email protected]>
 Steven Elliot Harris <[email protected]>
 Taiki Sugawara <[email protected]>
 Viacheslav Chimishuk <[email protected]>
+Will <[email protected]>
 Yasuyuki Oka <[email protected]>
diff --git a/go-mode.el b/go-mode.el
index dac2a38..f3ca05e 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1117,8 +1117,12 @@ with goflymake \(see URL 
`https://github.com/dougm/goflymake'), gocode
               (search-forward "flag provided but not defined: -srcdir" nil t)))
           (insert "Your version of goimports is too old and doesn't support 
vendoring. Please update goimports!\n\n"))
       (insert "gofmt errors:\n")
-      (while (search-forward-regexp (concat "^\\(" (regexp-quote tmpfile) 
"\\):") nil t)
-        (replace-match (file-name-nondirectory filename) t t nil 1))
+      (let ((truefile
+             (if (gofmt--is-goimports-p)
+                 (concat (file-name-directory filename) 
(file-name-nondirectory tmpfile))
+               tmpfile)))
+        (while (search-forward-regexp (concat "^\\(" (regexp-quote truefile) 
"\\):") nil t)
+          (replace-match (file-name-nondirectory filename) t t nil 1)))
       (compilation-mode)
       (display-buffer errbuf))))
 

Reply via email to