danielfalk / smart-open.nvim

Neovim plugin for fast file-finding
MIT License
470 stars 22 forks source link

Error on 0.2 branch when opening and the picker list contains an entry with no name #20

Closed lougreenwood closed 1 year ago

lougreenwood commented 1 year ago

I noticed this bug appearing recently, if the results list contains a directory then the result does not have a name, which seems to trigger the error message.

Screenshot 2023-05-10 at 07 58 19 Screenshot 2023-05-10 at 07 59 39


Also, more generally, when opening I often see the Press ENTER or type command to continue message and the picker isn't populated until I press enter, this is not accompanied by any error - I'm not sure if this is related and only seems to happen when opening for the first time:

Screenshot 2023-05-10 at 07 57 40

EDIT: Actually, for this second issue, it seems that it's triggered by a warning: 🎥 example

danielfalk commented 1 year ago

It appears that somehow, a directory entry got into the history database. I've pushed a change to the branch that will filter that out. I can't reproduce the issue with the warning that gets printed, but I think it might be due to the attempt to highlight directory entries (which this new change will filter out anyway). If you could give it a shot and let me know if it resolves that issue, I'd appreciate it!

lougreenwood commented 1 year ago

I'm not sure it's working - should I also clear the history (and then somehow get a dir into the history) when testing.

Here's a video showing the error still happening with verification of being on the latest release: https://monosnap.com/file/IL1ig76d4EKpUW6DFCrVkJzJG8gScU

Let me know if I can do anything else to help debug this 👍

danielfalk commented 1 year ago

Yeah I'm stumped. I think what might help is a dump of the history database (named smart_open.sqlite3) or better yet the entire file. I think that there's an entry in there with something different about it perhaps.

cshuaimin commented 1 year ago

@lougreenwood If you are using AstroNvim, I found that AstroNvim's devicons overrides is missing name field here, which leads to devicons not returning hl_groups. Either adding a name to AstroNvim's devicons config or changing smart-open.nvim's this line fixes the error for me:

https://github.com/danielfalk/smart-open.nvim/blob/7ecefe78bf38c607982f1704ae7145e1109a368d/lua/telescope/_extensions/smart_open/display/make_display.lua#L120

-      table.insert(to_display, { icon .. " ", hl_group = { { { 1, 3 }, hl_group } } })
+      table.insert(to_display, { icon .. " ", hl_group = hl_group and { { { 1, 3 }, hl_group } } })
lougreenwood commented 1 year ago

@cshuaimin yes! This seems to have fixed it for me, thanks for sharing the knowledge!

I'm not familiar enough with Vim to know where the correct fix for this should live though - do you think AstroNvim needs fixing upstream, or is this a bug in smart-open not handling a wider set of config potentials?

@danielfalk WDYT?

danielfalk commented 1 year ago

I've pushed that fix. Thanks @cshuaimin for finding that!

@lougreenwood I don't know for sure either but I think that if you're providing overrides for dev icons, you normally provide a name. The examples in the docs do.

I've additionally pushed some tweaks to the highlighting so that it would highlight properly in neovim nightly. If you see any issues with the highlighting, please let me know!