Closed Freed-Wu closed 7 months ago
It's expected. The buffer document is not created by coc.nvim, or attached to coc.nvim's management, when you fire any actions to it, coc.nvim has no idea to handle it, an error is throwing.
Maybe we can try-catch to hide this error, but this brings another issue: no response on actions.
Oh, I see. Currently I add the following code to avoid this problem:
ftplugin/help.vim
:
nnoremap <silent><buffer> gx :<C-U>call pandoc#hypertext#OpenSystem()<CR>
xnoremap <silent><buffer> gx :<C-U>call pandoc#hypertext#OpenSystem(getline('.')[col('v') - 1:col('''>') - 1])<CR>
These functions come from https://github.com/vim-pandoc/vim-pandoc
Can we provide a fallback, when it will throw an error, use a traditional method to open the link under the cursor?
provide a fallback
The openLink
action returns true for success, you can check this in vim function to run gx
to open the link.
openLink action will throw an error and return nothing when fail. Can it return v:false when fail?
function! OpenLink() abort
try
CocActionAsync('openLink')
catch
call pandoc#hypertext#OpenSystem()
endtry
endfunction
Result from CocInfo
Describe the bug
If a document link is in a help buffer, it will throw error:
Reproduce the bug
Install vimtex,
Then press the hotkey to open the document link. Trigger the error.