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

Error while handling unicode characters in REPL #5755

Closed
nicolasstucki opened this issue Jan 20, 2019 · 12 comments · Fixed by #19744
Closed

Error while handling unicode characters in REPL #5755

nicolasstucki opened this issue Jan 20, 2019 · 12 comments · Fixed by #19744
Assignees
Labels
area:repl backlog No work planned on this by the core team for the time being. itype:bug
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Writing

scala> class 😃

and then backspace 3 times confuses the repl

scala> cclas

There is probably a wrong computation of the current cursor in presence of unicode characters.

@smarter
Copy link
Member

smarter commented Jan 20, 2019

is this a JLine bug ?

@liufengyun
Copy link
Contributor

Cannot be reproduced.

@nicolasstucki
Copy link
Contributor Author

Copy paste class 😃 into the REPL and then delete 3 characters. It still happens.

@nicolasstucki nicolasstucki reopened this Sep 14, 2019
@philwalk
Copy link
Contributor

I'm able to reproduce this FWIW

@smarter
Copy link
Member

smarter commented Aug 14, 2020

Can you reproduce this using the Scala 2.13.3 repl too? If so, it's a JLine bug and should be filed at https://github.com/jline/jline3/

@philwalk
Copy link
Contributor

Running on WSL ubuntu, I can't reproduce the problem in either the dotty REPL or the scala 2.13.3 REPL.
Running in the sbt scala console under Intellij IDE, unable to reproduce the problem.

Running on the Windows jdk, there are problems in both dotty and scala 2.13.3, although they differ. Below is a discription of what I think I'm getting, but I need to thoroughly verify the specifics of my Windows environment, since I'm having other problems with sbt.

Running dotty REPL in mintty/bash on Windows 10. the problem occurs exactly as described by @nicolasstucki.
Running the Scala 2.13.3 REPL in mintty/bash, there is an issue where all but the initial character can be deleted, but the initial 'c' remains.

Interestingly, if I enter the REPL from SBT, the problems go away, it only occurs when running the dotr script from the console.

@smarter
Copy link
Member

smarter commented Aug 15, 2020

Does it work when using the new Windows Terminal (https://github.com/microsoft/terminal) ?

@philwalk
Copy link
Contributor

philwalk commented Aug 15, 2020

Here's my experiment, performed on Windows 10 x64

  1. cd to a dotty project
  2. sbt console (sbt 1.3.13)
  3. paste "class 😃"
  4. hit "backspace" 3 times

Here's what remains:

scala> cclas

In case it matters, the only way I have been able to create a usable sbt environment (even when running cygwin bash) is to run the"sbt.bat"windows script.

@philwalk
Copy link
Contributor

philwalk commented Mar 9, 2021

Unable to reproduce this problem using sbt 1.4.7 in any of several Windows shell environments"

  • cygwin
  • mingw64
  • mingw32
  • msys-64
  • WSL-Linux

and across 4 terminals:

  • mintty
  • conemu
  • windows terminal
  • CMD.EXE

Perhaps this was fixed as a side-effect of recent changes.

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Mar 15, 2021

Now if I paste class 😃 in Mac I get

scala> class

Does not misalign anymore but it is a different regression with usicode characters.

Same happens if we paste the usicode character '😃' in a string

scala> ""
val res0: String =

@odersky odersky added the backlog No work planned on this by the core team for the time being. label Apr 5, 2022
@SethTisue
Copy link
Member

The weird/incorrect backspacing before reproduces for me on 3.3.1 and 3.4.1-RC1-bin-20240212-c529a48-NIGHTLY on MacOS. (I don't get the thing Nico mentions with the box — I see the smiley face.)

The problem doesn't happen in Scala 2.13.12 or 2.13.13. So it's possible it's a JLine bug and perhaps it would go away if Dotty were to upgrade to a newer JLine version — that's the first thing to try. 2.13.13 is on JLine 3.24.1, whereas here in this repo you're still on 3.19.

@hamzaremmal
Copy link
Member

If we add a new line between the class and the emojis and backspace, it does work correctly.

scala> class
     | 😃

hamzaremmal added a commit that referenced this issue Feb 26, 2024
Fixes #5755, #19704

Tested locally and the difference in behaviour was observed. I'm not
sure how to test it with the CI, if anybody has an idea, please let me
know. Also, this issue might be a problem sbt/sbt#7177


Tested as follow:
- Observe that the issue in `3.4.1-RC1`
```scala
scala-cli repl -S 3.4.1-RC1
Welcome to Scala 3.4.1-RC1 (17.0.7, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class 😃
// defined class 😃

scala> cclas
-- [E006] Not Found Error: -----------------------------------------------------
1 |clas
  |^^^^
  |Not found: clas - did you mean caps?
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala>
```
- Publish dotty locally with the correct jline version
- Observe that the issue is fixed
```scala
scala-cli repl -S 3.4.2-RC1-bin-SNAPSHOT
Welcome to Scala 3.4.2-RC1-bin-SNAPSHOT-git-174d4c6 (17.0.7, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class 😃
// defined class 😃

scala> clas
-- [E006] Not Found Error: -----------------------------------------------------
1 |clas
  |^^^^
  |Not found: clas - did you mean caps?
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala>
``
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:repl backlog No work planned on this by the core team for the time being. itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants