Sublime Forum

Expand Selection to Tag doesn't work for file formats other than .html

#1

Sublime Text Builds affected: 3126, 3139

To reproduce:

  1. Create any file that isnt .html - for example, foo.hbs
  2. Create a simple div tag with content. e.g. <div>Blah Blah</div>
  3. In the menu bar, go to Selection > Expand Selection to Tag

Expected result:
Blah Blah gets highlighted

Actual result:
Cursor disappears and nothing is highlighted

Note: This feature does work for .html files, just not any other file format. It was also working in a previous build (not sure which, but doesn’t work since I updated to 3126).
In front-end frameworks like Ember and React, having this feature available in .hbs and .jsx files would be ideal, since they use html elements/tags. I would expect it to work like Expand Selection to Quotes, which works on all file formats.

1 Like

#2

from my experience, Expand Selection to Tag works with anything scoped entity.tag (.html / .xml) - what scopes is your .hbs syntax setting for the <div>? (Tools menu -> Developer -> Show Scope Name while the caret is in the <div>)

0 Likes

#3

Hi, thanks for the reply

My scope for .hbs is: text.html.handlebars

Is there a way I can override the scope to include handlebars? or change the handlebars scope to work with the Expand Selection to Tag?

1 Like

#4

okay taking a look at https://github.com/daaain/Handlebars/blob/790f2b0222098a3a236bd9e91bb9a039eeca4d8e/grammars/Handlebars.json I can see that it is because it is using scopes punctuation.definition.tag.html instead of punctuation.definition.tag.begin.html and punctuation.definition.tag.end.html for the < and > parts of HTML tags respectively. I don’t know enough about the legacy tmLanguage format to be able to suggest how to fix it, however.

0 Likes