Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when the cursor is in the middle of words #489

Open
jidanni opened this issue Jan 6, 2021 · 1 comment
Open

Problems when the cursor is in the middle of words #489

jidanni opened this issue Jan 6, 2021 · 1 comment

Comments

@jidanni
Copy link

jidanni commented Jan 6, 2021

Today let's explore some cases of when the cursor is within a word, and
we hit TAB. We will use [ ] to indicated what character the cursor is
on. We will randomly choose some commands here, (sys..., find), to test.
But this bug report applies much wider. (Actually the sys... example isn't too good,
as it highly depends on the state of your system.)

Example 1:

# systemctl st[s]ystemd-resolved
BEEPS

(Hitting TAB flashes the screen / beeps.)
(Bad.)

Example 2:

# systemctl st[ ]systemd-resolved
start   status  stop

Excellent.
However in Example 1, couldn't the space been added for us?

Example 3:

# systemctl st systemd-reso[ ]
BEEPS

Hmmmm.

Example 4:

# systemctl stop systemd-res[o]lved.ser
# systemctl stop systemd-resolved.service[o]lved.ser

That's right. We are now looking at

# systemctl stop systemd-resolved.serviceolved.ser

(with the cursor still sitting on the final "o".)
(Hitting RET no will of course send the trailing junk to the program.)

Anyway, I hope through these examples I have illustrated that although
bash-completions works great when the cursor is at the end of the (last)
word, they don't work so great when the cursor is in the middle of
words.

Wait, here's one more.
Example 5:

# find x -e[m]p
-empty       -exec        -execdir     -executable

(Hey, didn't you see the 'p' at the end?!)

@jidanni
Copy link
Author

jidanni commented Jan 7, 2021

OK,

bind 'set skip-completed-text on'

fixes example 4 and 5, and at least doesn't seem to make anything else worse.

   skip-completed-text (Off)
          If set to On, this alters the default completion  behavior  when
          inserting  a  single match into the line.  It's only active when
          performing completion in the middle  of  a  word.   If  enabled,
          readline  does  not  insert  characters from the completion that
          match characters after point in the  word  being  completed,  so
          portions of the word following the cursor are not duplicated.

Then why isn't "on" the default? (OK, I will ask bug-bash.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant