Navigation Menu

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

Unexpected behaviour in line when deleting multi-bytes characters by pressing backspace key #135

Closed
wjun opened this issue Mar 26, 2014 · 1 comment

Comments

@wjun
Copy link

wjun commented Mar 26, 2014

Hello,

We tried to delete some multi-bytes characters such as Chinese or Japanese in jline, and four characters(either double-byte or single-byte character) are deleted when pressing backspace key the first time and then one-byte is deleted when clicking backspace key.

Ideally, one character, no matter double-byte or single-byte character, is deleted when pressing backspace key once.

This happens on both Windows and CentOS.

Jun

@nchammas
Copy link

nchammas commented Jul 7, 2014

+1

I am also seeing this issue in the Scala shell, which I am told uses JLine 2.

Here is a brief repro:

scala> "hi".getBytes
res0: Array[Byte] = Array(104, 105)

scala> "안녕".getBytes
res1: Array[Byte] = Array(-20, -107, -120, -21, -123, -107)

scala> "안녕".getChars
<console>:8: error: value getByChars is not a member of String
              "안녕".getByChars

Notice that the error output at the end does not match the input I gave the shell. My input reads .getChars, but the shell is complaining about a .getByChars. How did that happen?

After res1, I hit the up arrow in the shell and then backspaced 5 times to edit the line to say "안녕".getChars instead of "안녕".getBytes. It looks like the Korean characters in there somehow messed up the input buffer, and I did not actually delete all the characters I thought I had deleted. So what I saw on the input line at the end was not what the shell received.

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

3 participants