luckasRanarison / nvim-devdocs

Neovim DevDocs integration
MIT License
270 stars 20 forks source link

Error opening doc when the os window is small enough for the telescope preview to hide #68

Open benelan opened 12 months ago

benelan commented 12 months ago

I'm running into an error that occurs when the OS window containing neovim is small enough that the Telescope preview does not display. When selecting an item through Telescope I get the following error:

E5108: Error executing lua: ...hare/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/pickers.lua:75: Invalid 'replacement': Expected Lua table
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...hare/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/pickers.lua:75: in function 'open_doc'
        ...hare/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/pickers.lua:180: in function 'run_replace_or_original'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:257: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:256>

Let me know if you aren't able to repro and I'll try to put together a minimal config.

luckasRanarison commented 12 months ago

The issue happened because I reused the telescope preview buffer to avoid extra read operations but I haven't thought of the case where there is no preview... But it should be fixed now, thanks for the report!

benelan commented 11 months ago

Thanks for the quick fix! Unfortunately I'm still getting an error when doing the following:

  1. use a window large enough for the telescope preview to display
  2. Open the devdocs picker and make sure you can see the preview
  3. shrink the window to the point where the preview no longer displays (e.g. create a new neovim window, tmux pane, etc.)
  4. press enter, and see the following error:
E5108: Error executing lua: ...l/share/nvim/lazy/telescope.nvim/lua/telescope/utils.lua:424: Invalid windo
w id: 1004
stack traceback:
        [C]: in function 'nvim_win_set_buf'
        ...l/share/nvim/lazy/telescope.nvim/lua/telescope/utils.lua:424: in function 'win_set_buf_noautocm
d'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:401: in function '_teardown_func'
        ...zy/telescope.nvim/lua/telescope/previewers/previewer.lua:79: in function 'teardown'
        ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:1571: in function 'on_close_prompt'
        .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:386: in function 'run_replace_or_origi
nal'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'close'
        ...hare/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/pickers.lua:174: in function 'run_replace_or_origi
nal'
        ...re/nvim/lazy/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:257: in function <...hare/nvim/lazy/te
lescope.nvim/lua/telescope/mappings.lua:256>