Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jumping to definition in modified buffer #2054

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions autoload/go/def.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ function! go#def#Jump(mode) abort
" covers all edge cases, but now anyone can switch to godef if they wish
let bin_name = go#config#DefMode()
if bin_name == 'godef'
if &modified
" Write current unsaved buffer to a temp file and use the modified content
let l:tmpname = tempname()
call writefile(go#util#GetLines(), l:tmpname)
let fname = l:tmpname
endif

let [l:out, l:err] = go#util#Exec(['godef',
let l:cmd = ['godef',
\ '-f=' . l:fname,
\ '-o=' . go#util#OffsetCursor(),
\ '-t'])
if exists("l:tmpname")
call delete(l:tmpname)
endif
\ '-t']

if &modified
let l:stdin_content = join(go#util#GetLines(), "\n")
call add(l:cmd, "-i")
let [l:out, l:err] = go#util#Exec(l:cmd, l:stdin_content)
else
let [l:out, l:err] = go#util#Exec(l:cmd)
endif
elseif bin_name == 'guru'
let cmd = [go#path#CheckBinPath(bin_name)]
let buildtags = go#config#BuildTags()
Expand All @@ -35,7 +32,7 @@ function! go#def#Jump(mode) abort
let stdin_content = ""

if &modified
let content = join(go#util#GetLines(), "\n")
let content = join(go#util#GetLines(), "\n")
let stdin_content = fname . "\n" . strlen(content) . "\n" . content
call add(cmd, "-modified")
endif
Expand Down