Sublime Forum

Haml parser bug causes indented lines to be wrapped in curly braces

#1

This issue has been dogging me for a while now.

I’ve noticed that if I have an indented block of Haml, like so:

.some-block
  .some-block__child

and I try to add curly braces to the parent element… like so:

.some-block{
  .some-block__child

the indented children get wrapped in the closing curly brace… sometimes…

.some-block{
  .some-block__child
}

Much frustrate. Here’s a screengrab.

0 Likes

#2

Did you ever find a solution for this once @meowsus? It has been bugging me for a couple of years now, and I finally looked into how I can solve this…

0 Likes

#3

It’s the rather naive wrap_block command causing it. It’s part of ST’s Default package and is bound to { key.

	{ "keys": ["{"], "command": "wrap_block", "args": {"begin": "{", "end": "}"}, "context":
		[
			{ "key": "indented_block", "match_all": true },
			{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
			{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
			{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
		]
	},

A fix would require to unmap that key or add further contexts, e.g. certain syntaxes, which it should apply to, only.

It’s indeed annoying in multiple situations.

0 Likes