SI-9206 Fix REPL code indentation #4564
Conversation
|
One test got by me because --update-check will accidentally make a check file for a SessionTest, which has the checkfile as it were embedded in the session transcript. |
|
/rebuild Hoping it's one of those spurious IDE build failures. |
|
I guess not. I'd hate to bug him, but I wonder if @adriaanm knows if something around presentation compiler and OSGI has changed. Maybe I'll just sneak by his office and see if the door is open. If he has a door. |
|
Who needs doors if they have headphones. Try rebasing? I think we just merged a tandem PR with scalaide related to this, but happy hour may be playing tricks on me. |
Previously, handy `sys.BooleanProp.keyExists` ignored the property value. While trying not to make any real estate puns, this commit will let it go false if a value is supplied that is not true in the usual Java sense. But what is truth? Allows `scala -Dscala.color=off`, for example.
|
Yep, rebasing will fix that one. |
|
This is the rebased result. Is there a command to issue like rebuild or sync? Sorry I'm out of the loop. |
|
A test failed in validate-test@bb361e7 % diff /home/jenkins/workspace/scala-2.11.x-validate-test/test/files/jvm/interpreter-jvm.log /home/jenkins/workspace/scala-2.11.x-validate-test/test/files/jvm/interpreter.check
@@ -366,5 +366,5 @@ plusOne: (x: Int)Int
res0: Int = 6
res0: String = after reset
<console>:8: error: not found: value plusOne
- plusOne(5) // should be undefined now
- ^
+ plusOne(5) // should be undefined now
+ ^
|
|
Scabot answers to these commands. |
The scala shell prompt can be provided as either a system property or in compiler.properties. The prompt string is taken as a format string with one argument that is the version string. ``` $ scala -Dscala.repl.prompt="%nScala %s> " Welcome to Scala version 2.11.7-20150616-093756-43a56fb5a1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to have them evaluated. Type :help for more information. Scala 2.11.7-20150616-093756-43a56fb5a1> 42 res0: Int = 42 Scala 2.11.7-20150616-093756-43a56fb5a1> :quit ```
To make code in error messages line up with the original line of code, templated code is indented by the width of the prompt. Use the raw prompt (without ANSI escapes or newlines) to determine the indentation. Also, indent only once per line.
Only for exactly `-Dscala.repl.info`, include the complete version number string in the REPL prompt. One could imagine this is the mode for posting snippets to stackoverflow.
|
Thanks, Jason, now I see that I must check build history in Jenkins. I was dissuaded by the lack of links here. I moved changing the default \nscala> to %nscala> to the next commit, that actually fixes indentation fix-up. The old assumption was to drop one char only from prompt; that test did manual intp.reset(), the .check was two chars off because of double indent; but it's not obvious to me why the output was different for only that one test case. TODO, perhaps. Also, hash tag things that shouldn't be hard to reason about. |
|
The checks are always greener on the other side. |
|
They look pretty green from my desk, but I'm struggling to get 2.11.7 out the door in time as it is (to make matters worse the elevators are stopping on random floors today). |
|
Hope you don't mind my reopening and moving back to 2.11.7. I didn't make my deadline yesterday. |
|
@adriaanm I was just fixing pasting with a custom prompt. About to push it. |
|
The intention of the previous code was to obviate the ctl-D by finishing a pasted transcript with a prompt. But there's a bug if there's more than one such empty line. EDIT: The bug was not detecting Each empty line initiates replay, but next prompt is taken as an expression. Here res14 - res15 are pasted: |
But sans test.
We talk about bit rot but not about how dust accumulates on code that hasn't been swept since the last time the furniture was moved around.
There was a problem hiding this comment.
The double negation could do with some De Morgan. !(assigned !"true") --> The key exists in the map and is either the empty string or "true".
There was a problem hiding this comment.
You have to read the comment in a mirror. It's written from the standpoint of a falsifier, kind of like what do you ask a Cretan liar. How do I turn it off? Also, everyone knows that Father's Day is also Opposite Day.
|
LGTM, with suggestions that hopefully will, erm, prompt a follow-up PR. |
SI-9206 Fix REPL code indentation
`testBoth` cannot be a val in `Pasted`, as `Pasted` is inherited
by `object paste` in ILoop, which would cause `val testBoth` to
be initialized before `val PromptString` was:
```
object paste extends Pasted {
val PromptString = prompt.lines.toList.last
```
See https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-checkinit-2.11.x/417.
Introduced by scala#4564.
To make code in error messages line up with the original line of
code, templated code is indented by the width of the prompt.
Use the raw prompt (without ANSI escapes or newlines) to determine
the indentation.
Also, indent only once per line.