nushell / reedline

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

Rendering issue with ColumnarMenu and Suggestions that have a description #522

Open steveklabnik opened 1 year ago

steveklabnik commented 1 year ago

Platform I found this on Windows 11, but believe it to be not specific. Terminal software Windows Terminal, both nushell and powershell

Describe the problem you are observing.

Steps to reproduce

  1. create a sample program that shows the issue. The fastest way to do this is to use the "completions" example in the repo. The only problem is, it uses the DeafultCompleter, which doesn't take descriptions for the completion items. However, we can apply a very small diff to reedline itself:
diff --git a/src/completion/default.rs b/src/completion/default.rs
index 812c740..d4ac027 100644
--- a/src/completion/default.rs
+++ b/src/completion/default.rs
@@ -98,7 +98,7 @@ impl Completer for DefaultCompleter {

                                     Suggestion {
                                         value: format!("{}{}", span_line, ext),
-                                        description: None,
+                                        description: Some(String::from("extra")),
                                         extra: None,
                                         span,
                                         append_whitespace: false,

And now cargo run --example completions will show the issue.

  1. Run the example
  2. type "he" and then hit tab

The very first time you do this, you'll get weird rendering:

image

If you hit tab again, or an arrow key, or anything else, it'll fix itself:

image

and then on future renderings, it does the right thing.

This makes me really suspect it's some initial state being set up just incorrectly, but have not yet tried to actually diagnose the issue.

sholderbach commented 1 year ago

Good catch! menus are witchcraft, confirmed Can confirm that annoying behavior on Ubuntu/WSL. Can look into it in a few days.

HKalbasi commented 5 months ago

I'm also hitting this issue: image

And after pressing tab it will fix itself just like the OP: image