scala-ide / scala-worksheet

A Scala IDE plugin for a multi-line REPL (called worksheet)
96 stars 24 forks source link

Worksheet deletes code on save - Can you name a worksheet "queries"? #108

Open GlenKPeterson opened 11 years ago

GlenKPeterson commented 11 years ago

When I save the following worksheet (queries.sc):

object queries {
  case class Book(title: String, authors: List[String])
}

it deletes my code and replaces it with:

object queries {
  println("Welcome to the Scala worksheet")       //> Welcome to the Scala worksheet\
}

This is particularly annoying when I have typed a half-page of code afterwards and it all disappears on save (Ctrl-S), often with no way to undo. Having the above case class statement at the top of the file like this seems to trigger it.

Eclipse 3.7.2, Scala IDE 2.1-M2-20121018-1623-Typesafe, on 64-bit Ubuntu Linux 12.04

UPDATE: The moral of this story may be not to name a worksheet "queries." I did the same thing in a worksheet with a different name and had no issue.

dotta commented 11 years ago

Admittedly, the worksheet runtime goes nuts when naming a worksheet queries. I actually didn't managed to exactly reproduce the issue as reported, but I did notice there was an entry in the Eclipse Error Log (so I've opened another ticket #109).

That said, I think what you are experiencing is more than just a crash in the runtime. If I have to guess, it looks like a race-condition between the editor and the evaluator. I'll have to investigate.

Thanks a ton for reporting this!

eustachione commented 11 years ago

I've just experienced the same issue. I'm following the Coursera course on Functional Programming in Scala. In lecture 6, I created a worksheet called 'session' as per the lecture, and typed in most of the code for the examples in that lecture and on one of my saves all the code was deleted, and I was left with the boilerplate worksheet code as above:

object session {
  println("Welcome to the Scala worksheet")       //> Welcome to the Scala worksheet
}

Eclipse details Version: Indigo Service Release 2 Build id: 20120216-1857

Scala Plugin version: 3.0.0.v-2_10-2013