Skip to content

Commit

Permalink
allow :GoDoc on modified buffers (#1014)
Browse files Browse the repository at this point in the history
* allow :GoDoc on modified buffers
  • Loading branch information
bhcleek authored and fatih committed Aug 27, 2016
1 parent 9380cc4 commit 8de252a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions autoload/go/doc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function! go#doc#Open(newmode, mode, ...)
endif

let command = printf("%s %s", bin_path, join(a:000, ' '))
let out = go#util#System(command)
else
" check if we have 'gogetdoc' and use it automatically
let bin_path = go#path#CheckBinPath('gogetdoc')
Expand All @@ -95,11 +96,27 @@ function! go#doc#Open(newmode, mode, ...)
let offset = go#util#OffsetCursor()
let fname = expand("%:p:gs!\\!/!")
let pos = shellescape(fname.':#'.offset)

let command = printf("%s -pos %s", bin_path, pos)

if &modified
" gogetdoc supports the same archive format as guru for dealing with
" modified buffers.
" use the -modified flag
" write each archive entry on stdin as:
" filename followed by newline
" file size followed by newline
" file contents
let in = ""
let sep = go#util#LineEnding()
let content = join(getline(1, '$'), sep)
let in = fname . "\n" . strlen(content) . "\n" . content
let command .= " -modified"
let out = go#util#System(command, in)
else
let out = go#util#System(command)
endif
endif

let out = go#util#System(command)
if go#util#ShellError() != 0
call go#util#EchoError(out)
return
Expand Down

0 comments on commit 8de252a

Please sign in to comment.