Handlebars icon indicating copy to clipboard operation
Handlebars copied to clipboard

Curly brace matching broken, often mistakenly includes next block

Open jasonlav opened this issue 11 years ago • 8 comments

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

example

jasonlav avatar Oct 08 '14 20:10 jasonlav

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?

daaain avatar Oct 08 '14 21:10 daaain

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

jasonlav avatar Oct 08 '14 22:10 jasonlav

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.

jasonlav avatar Oct 09 '14 17:10 jasonlav

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 :(

daaain avatar Oct 21 '14 21:10 daaain

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

jasonlav avatar Oct 23 '14 15:10 jasonlav

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}}
}

jas avatar Oct 25 '14 18:10 jas

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.

GeoffreyBooth avatar Feb 22 '15 07:02 GeoffreyBooth

:+1:

victorwpbastos avatar Jan 19 '16 19:01 victorwpbastos