nushell / reedline

A feature-rich line editor - powering Nushell
https://docs.rs/reedline/
MIT License
525 stars 146 forks source link

Can't tab-complete to highlight autcomplete entries for certain files which share prefixes #833

Open 132ikl opened 2 days ago

132ikl commented 2 days ago

Platform Arch Linux Terminal software alacritty Nushell 71d604

It seems like under some circumstances I'm not able to press tab to highlight autocomplete for files. I think it's related to the files having the same prefix, but I'm not sure. I haven't fully bisected the issue, but I wasn't able to reproduce the issue on nushell 28a746 and was able to reproduce the issue on 71d604. There was a reedline update between those two commits which includes 2a57906, 4096b93, and 660a507. The latter seems the most related to the issue, so I suspect it's the culprint (@uek-1)

Steps to reproduce

In nushell,

  1. Make a new directory and cd into it
  2. touch testa testb testc
  3. ls test<TAB>, then continue to press tab. testc will not be highlighted, however you can still select it with right arrow.
uek-1 commented 1 day ago

Took a look at this, it is indeed caused by my changes. menu.can_partially_complete(...) resets the selected item to 0 which makes it impossible to continue past the second suggestion. I opened a PR that would fix this issue by returning false when the suggested partial completion is exactly equal to the input contents (https://github.com/nushell/reedline/pull/834). I think it's a little confusing that the function menu.can_partially_complete() mutates at all - it might make more sense to split it into two different functions.