nvim-telekasten/telekasten.nvim

[BUG] Insert link without selection returns nil error

niderhoff opened this issue · 3 comments

Please confirm

  • I am running the latest version of this plugin

Describe the bug
When executing insert_link and nothing is selected in Telescope, this error is shown:

E5108: Error executing lua: ...local/share/nvim/lazy/telekasten.nvim/lua/telekasten.lua:1284: attempt to index local 'selection' (a nil value)
stack traceback:
        ...local/share/nvim/lazy/telekasten.nvim/lua/telekasten.lua:1284: 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>

To Reproduce
Steps to reproduce the behavior:

  1. Start nvim
  2. require'telekasten'insert_link()
  3. type something so that the fuzzy picker will show 0 results and press enter
  4. See error

Expected behavior
Not sure? But my suggestions would that the note is created if it does not exists, or a link is created that points to the non-existing note, so later we can create it.

Screenshots
image

Operating system (please complete the following information):

  • OS: osx

Additional context
Add any other context about the problem here.

When executing insert_link and nothing is selected in Telescope, this error is shown

I confirm that I can reproduce this bug.

But my suggestions would that the note is created if it does not exists, or a link is created that points to the non-existing note, so later we can create it.

I believe this was the original behavior yes. I will have a look at it. Thank you for reporting that.

All right! When nothing is selected, this should use what was typed in the prompt for the link. The file will not be created straight away, but if you use follow_link it will then create it automatically as usual.

can confirm it works, great job and quick fix :)