Skip to content

Tab completion #7202

Closed
Closed

Description

@mo8it

Describe the bug

Tab completion seems to be broken starting with version 0.71.

See this comment: https://fosstodon.org/@jntrnr/109389406197343536

How to reproduce

  1. Open nushell
  2. Type ls (with space)
  3. Press Tab
  4. The completion options appear
  5. Press Tab again
  6. Nothing happens!
  7. Press Shift + Tab
  8. Completion moves to last option!

Expected behavior

Shift + Tab moves in the other direction, but Tab seems to be broken! It should go to the next completion. This was the behavior before version 0.71.

Screenshots

No response

Configuration

❯ version | transpose key value | to md --pretty

key value
version 0.71.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.65.0 (897e37553 2022-11-02)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.65.0 (4bc8f24d3 2022-10-20)
pkg_version 0.71.0
build_time 2022-11-09 17:52:12 +01:00
build_rust_channel release
features default, trash, which, zip
installed_plugins

Additional context

Tried with --config "" to ignore my config, but it is the same behavior.

Activity

  1. kamirr commented on Nov 22, 2022

    @kamirr
    Contributor

    Works on main for me.

    key value
    version 0.71.1
    branch main
    commit_hash e0577e1
    build_os linux-x86_64
    build_target x86_64-unknown-linux-gnu
    rust_version rustc 1.63.0 (4b91a6ea7 2022-08-08)
    rust_channel 1.63.0-x86_64-unknown-linux-gnu
    cargo_version cargo 1.63.0 (fd9c4297c 2022-07-01)
    pkg_version 0.71.1
    build_time 2022-11-22 23:13:59 +01:00
    build_rust_channel release
    features database, default, trash, which, zip
    installed_plugins
  2. fdncred commented on Nov 22, 2022

    @fdncred
    Contributor

    I believe this is the PR that changed this functionality. The intent Dan was going for was to have the arrow keys be the menu navigation instead of the tab key by default.

    This is how you can circumvent this behavior. Use a keybinding like this one.

        {
           name: trigger-completion-menu
           modifier: none
           keycode: tab
           mode: emacs
           event: { 
             until: [
               { send: menu name: completion_menu }
               { send: menunext }
               { edit: complete }
             ]
           }
        }
    

    and I have completion_menu defined in my menus section of the config.nu defined this way.

        {
          name: completion_menu
          only_buffer_difference: false
          marker: $"(char -u 1f4ce) "
          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
          }
          style: {
              text: { fg: "#33ff00" }
              selected_text: { fg: "#0c0c0c" bg: "#33ff00" attr: b}
              description_text: yellow
          }
        }
    
  3. mo8it commented on Nov 22, 2022

    @mo8it
    Author

    Using Tab to navigate is like using Alt + Tab to navigate in the desktop. It is something natural for almost every terminal user. I don't think that it is something that people have to configure.
    Also: Why does Shift + Tab work? It is not even consistent.
    Please revert that change then. Thanks a lot!

  4. fdncred commented on Nov 22, 2022

    @fdncred
    Contributor

    FWIW, I agree with you and I think this one line change should be reverted. However, I was trying to point out to you that it could be configured to act like you want it to now so you don't have to wait and see if it eventually gets reverted or not.

  5. mo8it commented on Nov 22, 2022

    @mo8it
    Author

    Sorry if I was harsh. Thanks for helping ❤️

  6. added
    A:completions
    A:configuration
    on Nov 23, 2022
  7. sholderbach commented on Nov 23, 2022

    @sholderbach
    Member

    I think the core intent of the underlying change was to support filling common prefixes while avoiding the surprising automatic completion of everything should your typing narrow the search space, but I think the broken Tab action is just an artifact of landing the config changes. We should resolve that first (and then polish the underlying completion setup) but I think reverting the change would cause another regression.

  8. valpackett commented on Dec 8, 2022

    @valpackett
    Contributor

    IMO instead of the surprising automatic completion, the default should be like how most shells work: "if there's only one result available, Tab completes, otherwise Tab completes up to the common prefix and then cycles".

    The keybinding thing above gets closer to that than ever before! Except for doing things when the menu is already open and you're typing more.

  9. upsala1 commented on Dec 21, 2022

    @upsala1

    I also encountered this issue today and fixed it by changing the mode of the keybind with name: completion_menu from
    mode: emacs to mode: [emacs vi_normal vi_insert]. I am using vi mode and for the completion_previous keybind it was already set to the list including vi_normal and vi_insert. I hope this is somewhat clear

  10. amtoine commented on Feb 8, 2023

    @amtoine
    Member

    i think i'm able to reproduce this in nushell version 0.75.1 on bea7ec3 👍

  11. dschrempf commented on May 9, 2023

    @dschrempf

    Hi! Cycling with the TAB key is still not working. For example cd f <TAB> will not cycle through folder1, folder2, etc. I am using the vi mode.

  12. fdncred commented on May 9, 2023

    @fdncred
    Contributor

    I have no issues tabbing on the latest main branch (0.79.1) in Windows or Linux, haven't tried Mac yet.
    tabbing

  13. amtoine commented on May 9, 2023

    @amtoine
    Member

    just built the latest revision but this does not work on my end 🤔

    my config

    should be 2a484a3e7...

    ╭────────────────────┬──────────────────────────────────────────╮
    │ version │ 0.79.1 │
    │ branch │ main │
    │ commit_hash │ 0ea973b78b57bb01ae0b58ecd1c02fda21184043 │
    │ build_os │ linux-x86_64 │
    │ build_target │ x86_64-unknown-linux-gnu │
    │ rust_version │ rustc 1.67.1 (d5a82bbd2 2023-02-07) │
    │ rust_channel │ 1.67.1-x86_64-unknown-linux-gnu │
    │ cargo_version │ cargo 1.67.1 (8ecd4f20a 2023-01-10) │
    │ build_time │ 2023-05-07 10:44:01 +02:00 │
    │ build_rust_channel │ release │
    │ features │ default, zip │
    │ installed_plugins │ │
    ╰────────────────────┴──────────────────────────────────────────╯

  14. dschrempf commented on May 9, 2023

    @dschrempf

    My config.nu file is minimal:

    let-env config = {
      edit_mode: vi
    }
    

    Could this be the issue? Do we need to configure tab cycling somehow? Maybe I missed something above. Cycling backwards with Shift+TAB works.

    EDIT: Also, I am on version 0.79.0.

  15. 1 remaining item

  16. fdncred commented on May 9, 2023

    @fdncred
    Contributor

    Could this be the issue?

    Yes, it could be because there are keybindings and menus in the default_config.nu.

    Namely, these keybindings

        {
          name: completion_menu
          modifier: none
          keycode: tab
          mode: [emacs vi_normal vi_insert]
          event: {
            until: [
              { send: menu name: completion_menu }
              { send: menunext }
            ]
          }
        }
        {
          name: completion_previous
          modifier: shift
          keycode: backtab
          mode: [emacs, vi_normal, vi_insert] # Note: You can add the same keybinding to all modes by using a list
          event: { send: menuprevious }
        }
    
    

    and this menu

          {
            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
            }
            style: {
                text: green
                selected_text: green_reverse
                description_text: yellow
            }
          }
    

    I know for a fact, that for me, with nu -n --no-std-lib the tab will not work for menu navigation and you have to use the arrow keys.

  17. dschrempf commented on May 9, 2023

    @dschrempf

    Isn't it weird to require special configuration to make tab cycling work?

  18. fdncred commented on May 9, 2023

    @fdncred
    Contributor

    Isn't it weird to require special configuration to make tab cycling work?

    Not if the default is to use arrow keys.

    Having said that, we might should change our default.

  19. dschrempf commented on May 10, 2023

    @dschrempf

    I see! Thanks for your help! Consider my vote on the TAB-cycle side 😄 !

    EDIT: It is a bit weird though that back-cycling with Shift-TAB works out of the box. I also do not see any problem with using both ways to cycle as defaults.

  20. dschrempf commented on May 10, 2023

    @dschrempf

    For reference: Using you menu and keybinding snippet, TAB cycling works.

    I also noticed an inconsistency in the keybinding configuration: one list uses commas, the other doesn't. I am aware that both ways are valid syntax, but it is a bit confusing to use both syntaxes right next to each other, isn't it?

  21. fdncred commented on May 10, 2023

    @fdncred
    Contributor

    one list uses commas, the other doesn't

    I'm sure it came from me copy-n-pasting it into my config from someon else's example years ago. I don't pay much attention to it but I'm also not against standardizing it.

    I'm not sure if anyone would object to tab/shift-tab being the defaults if someone wants to take that on. I'm not sure if it's reedline's defaults or nushell's defaults that we're using right now.

  22. Abdillah commented on Jun 21, 2023

    @Abdillah
    Contributor

    @fdncred In my case adding { send: menunext } config doesn't solve the problem in v0.80.0. Even with --no-config-file.

  23. fdncred commented on Jun 21, 2023

    @fdncred
    Contributor

    I use tab all the time. I don't understand what the issue is. I use this in my config file.

    menu

      {
        name: completion_menu
        only_buffer_difference: false
        marker: $"(char -u '1f4ce') "
        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
        }
        style: {
          text: { fg: "#33ff00" }
          selected_text: { fg: "#0c0c0c" bg: "#33ff00" attr: b}
          description_text: yellow
        }
      }
    

    keybinding

      {
        name: trigger-completion-menu
        modifier: none
        keycode: tab
        mode: [emacs vi_normal vi_insert]
        event: { 
          until: [
            { send: menu name: completion_menu }
            { send: menunext }
            { edit: complete }
          ]
        }
      }
    
  24. Abdillah commented on Jun 21, 2023

    @Abdillah
    Contributor

    That actually works. But, I have double let-env unfortunately. Thanks!

  25. Abdillah commented on Jun 21, 2023

    @Abdillah
    Contributor

    Also, for everyone, this should works when nushell generate default configuration for us.
    The --no-config-file indeed remove the tab completion.
    And I vote for Tab as default because it has minimal movement (than arrow key).

  26. mpizenberg commented on Sep 3, 2023

    @mpizenberg

    I'd also be interested in having support for tab cycling by default. I like my config files clean and as small as possible.

  27. amtoine commented on Sep 3, 2023

    @amtoine
    Member

    this missing feature has annoyed me enough 😆
    can you check if #10199 solves this? 😇

  28. added a commit that references this issue on Sep 4, 2023
  29. added this to the v0.85.0 milestone on Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:completionsA:configuration

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions