Skip to content

Chuck does not remove preceding space #485

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

Closed
zmcgohan2 opened this issue Jan 16, 2022 · 4 comments
Closed

Chuck does not remove preceding space #485

zmcgohan2 opened this issue Jan 16, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@zmcgohan2
Copy link

image

"chuck ice"

image

@pokey
Copy link
Member

pokey commented Jan 16, 2022

Thanks for filing this one. We do need to make our space removal a touch more aggressive. The original implementation was too aggressive, and resulted in merged tokens, but I think we ended up pulling back a bit too far.

The policy I was thinking is as follows:

  1. If there are spaces on either side of the token, always remove one of them
  2. If the token is at start / end of a line (ignoring leading white space) and there is a space on the other side of it, remove the space
  3. Otherwise, if there is space on just one side of the token, remove it if and only if doing so will not cause the newly adjacent tokens to become a single token. For example, we don't want to remove the space if it ends up separating two alphanumeric tokens

Make sense? Cc/ @AndreasArvidsson

@pokey pokey added the bug Something isn't working label Jan 16, 2022
@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Jan 16, 2022

One and two is already implemented. What is missing is actually to check the tokenizer if we can remove the white space between two tokens without them becoming single. It not as easy as just check for alphanumerics because we have many more cases where two tokens can become one if you remove the space.
Easier solution is probably just pass the suggested change to the tokenizer and just see the result

@pokey
Copy link
Member

pokey commented Jan 16, 2022

Yep that's what I was thinking too 👍

One other thought is that we may want to do the check a bit further down the pipeline, because today's space removal can end up merging tokens if eg you say "chuck past air" and your cursor is sitting at the end of a token. For example, in the string big apple pie, if your cursor is at the end of big and you say "chuck past air", it will end up as bigpie

@pokey
Copy link
Member

pokey commented Jul 6, 2023

This already works today; was fixed by #1028

@pokey pokey closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants