jskinner / DefaultPackages

Old bug tracker for Sublime Text's "Default Packages", e.g. bad syntax highlighting
http://web.archive.org/web/20150524043750/https://www.sublimetext.com/forum/viewtopic.php?f=2&t=12095
26 stars 2 forks source link

Unknown self-closing tags are auto-completed on </ in HTML #176

Closed FichteFoll closed 7 years ago

FichteFoll commented 8 years ago

Branched off from #78.

This works as expected for tags like <img /> but not for seemingly arbitrary tags.

Reproduction

Have the following text in an HTML file (or syntax):

<template>
<price />
<tag></tag>

When typing </ at the end it closes with </price>.

Expected behavior: Complete to </template>.

keith-hall commented 8 years ago

Surely the expected behavior from the example should be to close the template tag?

FichteFoll commented 8 years ago

Ah, yes. Edited.

keith-hall commented 7 years ago

It seems the way the close_tag command works is that it checks if the / before the > is scoped as punctuation.definition.tag.end.html - if it is, then it is skipped when finding the open tag that needs to be closed. So we can update the syntax definition to scope the / if it exists before the >.

i.e change https://github.com/sublimehq/Packages/blob/54340707ecbf7de99ab5b02b9414258bd27ed403/HTML/HTML.sublime-syntax#L218 and https://github.com/sublimehq/Packages/blob/54340707ecbf7de99ab5b02b9414258bd27ed403/HTML/HTML.sublime-syntax#L208 to look like https://github.com/sublimehq/Packages/blob/54340707ecbf7de99ab5b02b9414258bd27ed403/HTML/HTML.sublime-syntax#L148