1. Tony Sloane
  2. ScalaWorksheet
  3. Issues


Issue #1 resolved

Long input lines cause some sort of wrapping error

Tony Sloane
repo owner created an issue

If you have an input line that is more than 80 characters long, the Scala REPL appears to echo it with a carriage return (\r) character at the 80 character boundary. This confuses the plugin because it then can't get the input line properly since some of it gets put on the next line by Sublime Text. Hence the output view ends up messed up a bit.

This one is eluding a solution because we can't reproduce it outside Sublime Text. Running the same commands from Python 3 outside do not suffer from the same symptom. So, there is something different about the Sublime

Note: this bug occurs even if we change the shell command that that the plugin uses to something like

scala <file.scala >/tmp/x.txt

When run from the plugin this command results in x.txt having the spurious carriage return, but if we run it from an terminal shell or from Python outside ST the carriage return does not show up. This tells us at least that it doesn't appear to be anything to do with ST doing word wrapping or something to the output.

Comments (6)

  1. Tony Sloane reporter

    Slight modification to what I appear to say above: The spurious \r does show up if we run a similar command from a Mac shell. E.g., running

    scala <Test.scala >x.txt

    where Test.scala is this file:

    val x = "dsfhsjdfhsfjshfsjfhsjfshfjshfjshfjsfhsjfhsfjhsdjfsdhfjsfhsjfhsdjfhsjfhsdfjsdfhsjfhsjfsfjshfjsfhsjfhsjfhsjfhsfjhsjfhsfjhsjfsjfhsdjfsfhsjfsjdfhsfdsfhsjdfhsfjshfsjfhsjfshfjshfjshfjsfhsjfhsfjhsdjfsdhfjsfhsjfhsdjfhsjfhsdfjsdfhsjfhsjfsfjshfjsfhsjfhsjfhsjfhsfjhsjfhsfjhsjfsjfhsdjfsfhsjfsjdfhsfxxx"

    results in x.txt containing a \r essentially every 80 characters in the echoed form of the Scala code but not the output of the REPL.

  2. Tony Sloane reporter

    For now, commit 158a3e1 solves this one by working around the JLine feature that causes this behaviour.

    There doesn't seem to be a better way to do it with the current JLine which defaults to adding space-CR characters at column 80 when the input doesn't come from a terminal.

  3. Dan Sănduleac

    I'm having the same issue but when using the terminal (mintty terminal under cygwin). I noticed that setting TERM=cygwin env-var convinced JLine not to do that anymore. Might that work for you as well?

  4. Tony Sloane reporter

    Thanks Dan. Yes, I tried various combinations of setting the TERM var or setting the width via stty but none of them work. The reason for the failure is that JLine (at least modern one) ignores the terminal settings if input is not coming from a terminal.

    The plugin sends input to the scala command via a redirection (ie. scala <foo.scala) since we want to simulate typing the code by hand. The redirection means that input is not from the terminal. JLine under those circumstances defaults to a terminal width of 80 and there doesn't appear to be any way to stop it doing so.

  5. Log in to comment