Skip to content

Improve tab completion method (respect for the behaviors of major interactive shells in Unix) #2835

@tats-u

Description

@tats-u

Description of the new feature/enhancement

Consider the case that only these sub-directories are in the current directory:

  • 📂 directory_barbarbarbarbarbarbarbarbarbar
  • 📂 directory_foofoofoofoofoofoofoofoofoofoo
  • 📂 directory_foofoofoofoofoofoofoofoofoofoo_001
  • 📂 directory_foofoofoofoofoofoofoofoofoofoo_002
  • 📂 directory_foofoofoofoofoofoofoofoofoofoo_100
  • 📂 directory_quxquxquxquxquxquxquxquxquxqux

If you want to enter the directory_quxquxquxquxquxquxquxquxquxqux by cd, the current behavior of PSReadLine is:

1️⃣

PS> cd␣

Tab

2️⃣

PS> cd␣.\directory_barbarbarbarbarbarbarbarbarbar

\AHHHHH!!! IT'S A PAIN OF AΣΣ TO DELETE THE SOOOO LONG SUFFIX!!!/

Tab

2️'

PS> cd␣.\directory_foofoofoofoofoofoofoofoofoofoo

Tab

2️''

PS> cd␣.\directory_foofoofoofoofoofoofoofoofoofoo_001

\HOW MANY TIMES DO I HAVE TO PRESS TAB!?!?/

The current behavior is not suitable for this situation.

Proposed technical implementation details (optional)

The first Tab should complete only the common prefix like (the new state 1️⃣' is added):

1️⃣

PS> cd␣

Tab

1️⃣'

PS> cd␣.\directory_

Tab

2️⃣

PS> cd␣.\directory_barbarbarbarbarbarbarbarbarbar

Tab

2️'

PS> cd␣.\directory_foofoofoofoofoofoofoofoofoofoo

If you want to enter directory_quxquxquxquxquxquxquxquxquxqux, you just have to press q then Tab when 1️⃣'.

FYI: Bash's behavior:

  1. Completes only the common prefix (1️⃣')
  2. Shows candidates
  3. Shows candidates

The behavior of Fish and Zsh:

  1. Complete only the common prefix (1️⃣')
  2. Shows candidates
  3. Choose the 1st candidate (2️⃣)
  4. Choose the 2nd one (2️⃣')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions