diff options
Diffstat (limited to 'plugin/haredoc.vim')
| -rw-r--r-- | plugin/haredoc.vim | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugin/haredoc.vim b/plugin/haredoc.vim index 1ff141c..256ac9f 100644 --- a/plugin/haredoc.vim +++ b/plugin/haredoc.vim @@ -36,14 +36,20 @@ function Haredoc(symbol) endif if goto - let haredoc_output = system('haredoc -N '..symbol) + let line = search('^fn '..symbol, 'bnw') - if match(haredoc_output, ":") != 1 - let [filepath, line] = split(haredoc_output, ":")[-2:-1] - - execute 'edit +'..line..' '..filepath + if line != 0 + execute line else - execute "echo '"..haredoc_output.."'" + let haredoc_output = system('haredoc -N '..symbol) + + if match(haredoc_output, ":") != 1 + let [filepath, line] = split(haredoc_output, ":")[-2:-1] + + execute 'edit +'..line..' '..filepath + else + execute "echo '"..haredoc_output.."'" + endif endif elseif popup && has('popupwin') && has('terminal') let buf = term_start( |
