atom / language-coffee-script

CoffeeScript support in Atom
Other
59 stars 56 forks source link

Anonymous functions as default arguments breaks syntax highlighting in literate mode #153

Closed nathancarter closed 7 years ago

nathancarter commented 7 years ago

Description

In Literate Coffeescript files, within a class definition, if a member function has parameters that have default arguments, and one of those default arguments is a function, then subsequent documentation lines are treated as if they are code, and thus all syntax highlighting for the rest of the file is hideously broken.

Steps to Reproduce

  1. Open a new file in Atom.
  2. Save it with a .litcoffee extension.
  3. Enter code as described above, or just use the example below.
This is example text.

    class Example

More example text, correctly formatted.

        debug: ( args... ) -> console.log args...

More example text, correctly formatted.

        foo: ( callback = ( result, error ) => @debug result, error ) =>

Uh oh, this text is not correctly formatted.  It thinks it's code.

            callback null, null

Oh my, it's getting worse! :(

Expected behavior: Unindented text in .litcoffee files should NEVER be syntax highlighted as if it were code. Basically, exactly what the GitHub .litcoffee renderer does with the code above, in this very page.

Actual behavior: From the point in the file at which the anonymous function appears as a default argument to another function, all text in the file is syntax highlighted as if it were code. See here:

screen shot 2017-10-12 at 10 58 00 am

Reproduces how often: 100%

Versions

Atom : 1.21.0

Electron: 1.6.9

Chrome : 56.0.2924.87

Node : 7.4.0

Mac OS X 10.11.6

nathancarter commented 7 years ago

I don't know if this is related to #154 but the end result of both problems is the same: unindented text in a .litcoffee file should never be anything but Markdown, and to see it treated otherwise is a rather significant syntax highlighting problem.