nushell / reedline

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

fix ide menu not reporting correct required_lines #781

Closed maxomatic458 closed 7 months ago

maxomatic458 commented 7 months ago

closes #753

stormasm commented 7 months ago

@maxomatic458 I am no longer seeing an issue with nushell and reedline in the latest nushell main...

when I type "str" on my mac in a ghostty terminal it all looks good...

I am not seeing what this issue is reporting https://github.com/nushell/reedline/issues/753

Everything looks fine to me...

maxomatic458 commented 7 months ago

@stormasm it only happens when max_completion_height is less then the number of suggestions

name: completion_menu
        only_buffer_difference: false
        marker: ""
        type: {
            layout: ide
            max_completion_height: 5
            ...
        }

can you replicate it with this config?

stormasm commented 7 months ago

@maxomatic458

see my config below...

I changed it to 5 but for the str example I am still seeing the exact same thing as before... No changes... I am seeing everything...

    menus: [
        # Configuration for default nushell menus
        # Note the lack of source parameter
        {
            name: completion_menu
            only_buffer_difference: false
            marker: "| "
            type: {
                layout: columnar
                columns: 4
                col_width: 20     # Optional value. If missing all the screen width is used to calculate column width
                col_padding: 2
                max_completion_height: 5
            }
            style: {
                text: green
                selected_text: { attr: r }
                description_text: yellow
                match_text: { attr: u }
                selected_match_text: { attr: ur }
            }
        }
        {
            name: ide_completion_menu
            only_buffer_difference: false
            marker: "| "
            type: {
                layout: ide
                min_completion_width: 0,
                max_completion_width: 50,
                max_completion_height: 5, # will be limited by the available lines in the terminal
                padding: 0,
                border: true,
                cursor_offset: 0,
                description_mode: "prefer_right"
                min_description_width: 0
                max_description_width: 50
                max_description_height: 10
                description_offset: 1
                # If true, the cursor pos will be corrected, so the suggestions match up with the typed text
                #
                # C:\> str
                #      str join
                #      str trim
                #      str split
                correct_cursor_pos: false
            }
stormasm commented 7 months ago

https://github.com/nushell/reedline/assets/1809991/deed752f-9f18-4c50-8e60-c50b743afb2d

stormasm commented 7 months ago

So I guess the max_completion_height is not kicking in either as I am seeing more than 5 ?

stormasm commented 7 months ago

hold on my layout is columnar instead of ide let me change it...

maxomatic458 commented 7 months ago

also to see the bug you need to make sure your current prompt is at the end of the terminal

stormasm commented 7 months ago

@maxomatic458 I was finally able to reproduce the bug 😄

And your code indeed fixes it !! Thank you... And I am going to go ahead and land your PR...

stormasm commented 7 months ago

Also one other thing @maxomatic458 Please remember to create a branch any time you submit a PR... This way we can test the latest and greatest code... There was a minor PR that came in after your fix... So I didn't actually check the latest and greatest code... But since it was just a print statement it didn't matter....