Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix backwards character deletion on other whitespaces #2855

Merged
merged 4 commits into from
Jul 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,7 @@ pub mod insert {
for _ in 0..drop {
// delete up to `drop` spaces
match chars.next() {
Some(' ') => start -= 1,
Some(c) if c.is_whitespace() => start -= 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't work correctly with whitespace that has a wider width than 1 (eg. space used in Japanese text).

The body of this function should be extracted into helix-core and properly unit tested.

Copy link
Contributor Author

@SoraTenshi SoraTenshi Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't work correctly with whitespace that has a wider width than 1 (eg. space used in Japanese text).

Well the Japanese text spaces are Ideographic Spaces.
I also filed this bug because i am using a japanese ime quite frequently.

This change has been tested locally, and works.

However i see what you mean, would it maybe make sense to something similar as the width variable for the substraction of the pos?

Some(c) if c.is_whitespace() => start -= c.width().unwrap_or(1),

_ => break,
}
}
Expand Down