hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

100% CPU with triple-quoting #38

Closed dchenbecker closed 11 years ago

dchenbecker commented 11 years ago

Opening a scala file with the following content causes Emacs to run at 100% cpu for a very long time (I gave up waiting after 5 minutes). If I C-g to cancel the mode run the quoting is highlighted incorrectly.

Thanks,

Derek

Content:

package foo.bar

import org.specs2.mutable.Specification

class FullCpuSpec extends Specification {
  "foo" should {
    "Sloops lagrange" in {
      val inputs = """[
{ "foo" : "1234", "bar" : "baz blarg", "bazs" : [   "1234", "1234"] },
{ "foo" : "12345678", "bar" : "blergh", "bazs" : [  "1234", "1234"] },
{ "foo" : "12345678", "bar" : "blergh", "bazs" : [  "1234", "1234"] },
{ "foo" : "12345678", "bar" : "blergh", "bazs" : [  "1234", "1234"] },
{ "foo" : "12345678", "bazs" : [ "1234", "1234"] }
]"""
    }
  }
}
hvesalai commented 11 years ago

I have experienced the same my self just a few days ago. Still haven't looked into it.

I think it has something to do with those quotes inside the triple quotes.

Also, if you first close the triple quotes and only then start writing its content, then the problem won't appear.

I will look into it.

hvesalai commented 11 years ago

Ok. The culpit is obviously scala-syntax:propertize-char-and-string-literals function, which does funny things for single quote strings inside triple quote strings when the triple quote string is not balanced. That's the reason it is only triggered in this special case.

I don't have time to fix it right away, so if anybody else would like to take a shot, I'd be happy. Otherwise, expect a fix in a week or so.

As a workaround: close your triple quoted string before you start writing anything into it.