Last time, When i press enter between the element, the cursor will indent like that.
Before i press enter:
After I press enter.
Then when i did the latest udpate, this thing just happened.
Please help me fix the issue.
Thanks in advance.
Last time, When i press enter between the element, the cursor will indent like that.
Before i press enter:
After I press enter.
Then when i did the latest udpate, this thing just happened.
Please help me fix the issue.
Thanks in advance.
I have the latest update and it still formats as
after hitting enter… it may be a plugin you have thats messing it up
it looks like the default keybinding is set to operate on scope meta.scope.between-tag-pair
, which is no longer set by the HTML syntax (tested in build 3109) - instead the scope at <div>|</div>
is text.html.basic meta.tag.block.any.html punctuation.definition.tag.begin.html
, so it will need a fix in the default HTML package. It still works for XML.
Here is the default keybinding:
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selector", "operator": "equal", "operand": "meta.scope.between-tag-pair", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
]
}
could it be this commit here @wbond? https://github.com/sublimehq/Packages/commit/57d04205f74069bcfb72a5735e46a1db08b5d8c4
Oh, that is an interesting find. I recently worked on HTML, improving performance and merging in a number of changes. I vaguely remember seeing a match for a pair of HTML tags that ended up breaking other highlighting that took into account the type of tag it was.
I’ll look into getting this functionality working with the current state of the world.
@wbond in case it is non-trivial to “fix” the syntax definition while keeping the performance improvements, maybe it is worth considering writing a small, simple on_query_context
plugin that the keybinding can use to determine when the cursor is directly between a matching opening and closing tag, what do you think?
I guess it would be necessary to find out if any plugins make use of this scope, and thus whether it needs to be kept or not… anyway, just an idea
Confirmed fixed in 3110 .How did you tackle this in the end @wbond?
EDIT: if I understand right, you created a new command auto_indent_tag
and updated the default keybindings to not require the meta.scope.between-tag-pair
scope?
I just downloaded Sublime 3, I am still having issues with the auto indent. When I hit enter from the following position (see screenshot) auto-indent does not work (not allowed to add another image but you get the drift; the cursor is not indented).
Before I hit enter:
Thanks
TL;DR: auto indent for HTML only works at <div>|</div>
by default - you’ll need to modify the indentation rules to achieve what you want