telescope-project.nvim icon indicating copy to clipboard operation
telescope-project.nvim copied to clipboard

Crash when switching to a non-existent project

Open jubnzv opened this issue 3 years ago • 1 comments

When we try to switch to a non-existent project, the plugin crashes. I think it would be nice to handle such cases and display a warning message to the user.

To reproduce:

  1. Open telescope-project and enter the name of some non-existent project: image
  2. Press Enter to see the crash: image
E5108: Error executing lua ...oject.nvim/lua/telescope/_extensions/project/actions.lua:18: attempt to index a nil value                                                                                              
stack traceback:                                                                                                                                                                                                     
        ...oject.nvim/lua/telescope/_extensions/project/actions.lua:18: in function 'get_selected_path'                                                                                                              
        ...oject.nvim/lua/telescope/_extensions/project/actions.lua:101: in function 'run_replace_or_original'                                                                                                       
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'find_project_files'                                                                                                             
        ...-project.nvim/lua/telescope/_extensions/project/main.lua:73: in function 'run_replace_or_original'                                                                                                        
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'                                                                                                                       
        ...e/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:235: in function 'execute_keymap'                                                                                                                
        [string ":lua"]:1: in main chunk 

jubnzv avatar Dec 08 '21 13:12 jubnzv

It seems, that we could modify the M.get_selected_title and M.get_selected_path functions from actions.lua to make them return a nil value if there is no such project.

jubnzv avatar Dec 08 '21 13:12 jubnzv