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

M-d sometimes deletes more than one word #4747

Closed
mithrandi opened this Issue Feb 23, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@mithrandi
Copy link

mithrandi commented Feb 23, 2018

Originally reported at https://bugs.debian.org/885397 and reproducible with fish 2.7.1.

When I delete a word with M-d (Alt + D), Fish ignores single-letter
words under the cursor. For example, if I've typed

	~> ls dir1 dir2 dir3
	      ^

and have my cursor at the marked ^, M-d deletes the word dir1:

	~> ls  dir2 dir3
	      ^

However, if the arguments are single letters—e.g.,

	~> ls a b c
	      ^

M-d deletes both a and b:

	~> ls  c
	      ^

This behavior does not appear terminal-linked; I can reproduce both in
xterm and in rxvt-unicode. It also does not occur if I have my cursor
on the space before the letter: M-d on

	~> ls a b c
	     ^

yields

	~> ls b c
	     ^

as expected.

@faho

This comment has been minimized.

Copy link
Member

faho commented Feb 25, 2018

I can reproduce this. I'd imagine our state machine is off-by-one somewhere.

@faho

This comment has been minimized.

Copy link
Member

faho commented Feb 25, 2018

Yup, what happens is:

The state-machine starts in "s_always_one", removes the "a", then goes to "s_whitespace". It consumes the whitespace, goes to "s_alphanumeric", and consumes alphanumeric characters until it finds something that isn't alphanumeric.

We want to change this particular case, but I'm not quite sure what behavior we want exactly.

Because one of our tests does successive "forward-word" (which moves just like kill-word does) through echo foo_foo_foo/////. With ^ denoting the cursor positions, the current behavior is:

echo^ foo^_foo^_foo^/^/^/^/^/    ^

These jumps from ^_foo to foo^_ use that, which is much nicer than one "forward-word" just going over the _ and stopping.

faho added a commit to faho/fish-shell that referenced this issue Feb 25, 2018

Fix punctuation movement with one char tokens
Previously, in

    ls ^a bcd

(with "^" as the cursor), kill-word would delete the "a" and then go
on, remove the space and the "bcd".

With this, it will only kill the "a".

Fixes fish-shell#4747.

@faho faho closed this in c793570 Feb 27, 2018

@faho

This comment has been minimized.

Copy link
Member

faho commented Feb 27, 2018

Okay, this should be fixed now.

@faho faho added the bug label Feb 27, 2018

@faho faho added this to the fish-3.0 milestone Feb 27, 2018

@EvanTheB

This comment has been minimized.

Copy link

EvanTheB commented Jan 10, 2019

C-w has a similar strange behaviour.

ls /abc
      ^
-> ls /

ls a
   ^
-> ls

ls /
   ^
-> 

If the last arg is a bare slash extra characters are deleted. Maybe this matches the definition of word used, but it is not expected or I think useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment