Skip to content

Commit f6c8b14

Browse files
authored
Merge pull request #21 from jimeh/fix-upload
fix: go-playground-upload not working in playground snippet buffers
2 parents b021ef5 + 2591a49 commit f6c8b14

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

go-playground.el

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,9 @@ Tries to look for a URL at point."
222222
(defun go-playground-upload ()
223223
"Upload the current buffer to play.golang.org and return the short URL of the playground."
224224
(interactive)
225-
(if (go-playground-inside)
226-
(goto-char (point-min))
227-
(forward-line)
228-
(insert (go-play-buffer))))
225+
(if (not (go-playground-inside))
226+
(message "Not in a Go Playground buffer!")
227+
(go-play-buffer)))
229228

230229
(defun go-playground-snippet-unique-dir (prefix)
231230
"Get unique directory under GOPATH/`go-playground-basedir`."
@@ -237,8 +236,10 @@ Tries to look for a URL at point."
237236

238237
(defun go-playground-inside ()
239238
"Is the current buffer is valid go-playground buffer."
240-
(if (string-match-p (file-truename go-playground-basedir) (file-truename (buffer-file-name)))
241-
(bound-and-true-p go-playground-mode)))
239+
(and (bound-and-true-p go-playground-mode)
240+
buffer-file-name
241+
(string-prefix-p (file-truename go-playground-basedir)
242+
(file-truename buffer-file-name))))
242243

243244
(provide 'go-playground)
244245
;;; go-playground.el ends here

0 commit comments

Comments
 (0)