daaain / Handlebars

Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://packagecontrol.io/packages/Handlebars.
MIT License
301 stars 48 forks source link

Curly brace matching broken, often mistakenly includes next block #52

Open jasonlav opened 10 years ago

jasonlav commented 10 years ago

When adding handlebars indented with HTML below, the close curly braces are not added to the appropriate place.

example

daaain commented 10 years ago

Just tried to reproduce but this doesn't happen to me. Might be a combination with some other package? Could you please try temporarily disabling other packages and see if it still happens?

jasonlav commented 10 years ago

Reproduced it with a clean installation of Sublime Text 3. I tried text and tab indentation and both had the same issue.

jasonlav commented 10 years ago

It appears to ONLY be an issue if there is a single tag in the body. For example, if I have a 2nd P tag below the "Example copy" it doesn't do it.

daaain commented 9 years ago

I finally managed to reproduce it, although it doesn't always happen.

Still not really sure what's going on, but I do have a clue. When looking at the scope, this is what ST says: Scope: text.html.handlebars source.smarty.embedded.html.

There's not a single mention of Smarty in this Handlebars package, so this seems to be something inherited from the built in HTML definitions. The HTML5 package has it too: https://github.com/mrmartineau/HTML5/blob/master/Syntaxes/HTML%205.YAML-tmLanguage#L224

The only solution I can think of right now is to redefine a big chunk of the HTML package to override this behaviour, but that's a bit of a pain to maintain :(

jasonlav commented 9 years ago

No worries. Thanks for taking a look. It is a very narrow niche case bug; I doubt many will run into it.

jas commented 9 years ago

I don't think this issue is limited to when body contains only a single tag. I actually run into this quite frequently, even in larger Handlebars files. The problem also sometimes occurs for me when typing above a Handlebars expression. For example:

{{
{{someValue}}
}
GeoffreyBooth commented 9 years ago

I run into this issue a lot. For example, if I want to wrap the p tag below inside a new {{#if}} block:

<div>
    <p></p>
</div>

When I start to type the {{#if on a new line inside the div but above the p, I get:

<div>
    {
    <p></p>
    }
</div>

Just like the original poster’s screen recording. I have lots of other HTML on this page, so it’s not confined to a single tag in a body.

victorwpbastos commented 8 years ago

:+1: