lambdahands / lt-scss

A SCSS plugin for LightTable
Other
8 stars 3 forks source link

SCSS auto-indent not matching code mirror functionality. #4

Closed zackmvmt closed 10 years ago

zackmvmt commented 10 years ago

First, thanks for making such an awesome plugin. This has worked out great except for one minor annoyance with the auto-indent functionality not matching code mirror.

When I place my cursor at the closing } of the .foo a style and hit enter, the next line is not indented correctly. It should be two indents in and it's currently zero indents in.

body {
    background-color: white;
    font-family: serif;
    .foo {
        background-color: lime;
        text-decoration: none;
        a {
            color: red;
        }
    }
}

Interestingly enough, when I try the same action with the same code on the code mirror site, it is handled correctly. http://codemirror.net/mode/css/scss.html

Am I doing something wrong, or is this a legitimate issue? It seems like there were a couple of issues with the code mirror indenting that got fixed a few months ago. Perhaps those fixes didn't make it to this plugin?

lambdahands commented 10 years ago

Hey, thanks for using the plugin!

This is a bug, yes. Oddly enough, I had encountered this issue while developing the plugin, and it seems to have somehow reappeared. LightTable had been using an old version of CodeMirror's css.js, so I dropped a newer version in that seemed to have fixed the issue for the time being.

I can take a closer look at this in the evening when I'm free. Hopefully it's as easy as updating the repository's version of css.js.

zackmvmt commented 10 years ago

I tried swapping the css.js file out with the one on the current code mirror repo and was unable to get the desired results. Admittedly, I don't know anything about light table plugins (not sure if it needs to be compiled).

One workaround I found was to switch the syntax to LESS when writing. Unfortunately, the SCSS auto-compile functionality doesn't work when saving (even when trying to apply the behavior on less files).

lambdahands commented 10 years ago

After some looking around, I tried replacing LighTable's core css.js found in its deployment package with the most recent CodeMirror version. That seemed to do the trick for me. While this is a hack around the problem, the main issue still remains as to why LT's own syntax files override custom loaded ones.

This is the offending file in LightTable. It was updated six months ago, four months before this fix was committed to CodeMirror.

This could be a bug in LightTable, but I'm going to do some more digging before I open an issue.

lambdahands commented 10 years ago

Added a merge request to LightTable. If you want to fix this in the meantime (WARNING: Hacky!), you can remove core/node_modules/codemirror/modes/css.js.

If you're using OS X, you can follow that path by first going into LightTable.app/Contents/Resources/app.nw/.

lambdahands commented 10 years ago

Fixed here. The next LightTable update will resolve this on its own.