Sublime Forum

Autocompletes adding extra opening tag

#1

I just noticed today, on an html file, if I type a <, then “tr” (for example) and choose the “tr” in the autocomplete suggestion popup, I get

<<tr></tr>

Which is, of course, wrong. The extra < is flagged as incorrect.
This is now happening on all html tags; p, td, etc.
Why is this happening?

0 Likes

#2

Handycam, what I noticed is that when I uninstalled Zen Code, I didn’t have that issue any longer.

Another issue I’ve noticed is that when I do the shortcut “li,tab” to create a list item, it expands to

  • (with a highlighted anchor element inside which is pretty cool) but also creates an “li” on the next line. THis is quite annoying because now I have to delete the extra “li”
  • 0 Likes

    #3

    I have also noticed both of the behaviours mentioned:

    I agree with Purewise that the first issue is being caused by the “Zen Coding” plugin. When I remove it this problem disappears.

    In my experience the second issue is being caused by the “HTML5” plugin. Removing this also corrects this problem of the extra “li” on the next line (but leaves me without the benefits of the plugin).

    Hopefully both the “Zen Coding” and “HTML5” plugins will have these issues corrected as both are otherwise really great.

    0 Likes

    #4

    [quote=“handycam”]I just noticed today, on an html file, if I type a <, then “tr” (for example) and choose the “tr” in the autocomplete suggestion popup, I get

    <<tr></tr>

    Which is, of course, wrong. The extra < is flagged as incorrect.
    This is now happening on all html tags; p, td, etc.
    Why is this happening?[/quote]

    Seems to be an artifact of the builtin setting to use < to trigger the auto-completion dialogue:
    [pre=#0C1021]// Additional situations to trigger auto complete
    “auto_complete_triggers”: {“selector”: “text.html”, “characters”: “<”} ],
    [/pre]
    There’s a builtin plugin to auto complete tags which Zen has always disabled. Note it doesn’t insert the <
    [pre=#0C1021]return (
    (“a\tTag”, “a href=”$1">$2"),
    (“abbr\tTag”, “abbr>$1”),
    (“acronym\tTag”, “acronym>$1”),
    (“address\tTag”, “address>$1”),[/pre]

    Zen does a reverse scan on the current line to find the current abbreviation which is was gets replaced by the full expansion.

    Zen will need to be patched to be aware of that change to Sublime.

    I’ve personally just changed my auto_complete_selector to show all the time, though my version of Zen is a bit ahead of what’s published. The old version, I think, has bugs that will surely litter the console with error messages. I started preparing a new release a week or so back but have since been distracted by work.

    0 Likes

    #5

    [quote=“castles_made_of_sand”]

    [quote=“handycam”]I just noticed today, on an html file, if I type a <, then “tr” (for example) and choose the “tr” in the autocomplete suggestion popup, I get

    <<tr></tr>

    Which is, of course, wrong. The extra < is flagged as incorrect.
    This is now happening on all html tags; p, td, etc.
    Why is this happening?[/quote]

    Seems to be an artifact of the builtin setting to use < to trigger the auto-completion dialogue:
    [pre=#0C1021]// Additional situations to trigger auto complete
    “auto_complete_triggers”: {“selector”: “text.html”, “characters”: “<”} ],
    [/pre]
    There’s a builtin plugin to auto complete tags which Zen has always disabled. Note it doesn’t insert the <
    [pre=#0C1021]return (
    (“a\tTag”, “a href=”$1">$2"),
    (“abbr\tTag”, “abbr>$1”),
    (“acronym\tTag”, “acronym>$1”),
    (“address\tTag”, “address>$1”),[/pre]

    Zen does a reverse scan on the current line to find the current abbreviation which is was gets replaced by the full expansion.

    Zen will need to be patched to be aware of that change to Sublime.

    I’ve personally just changed my auto_complete_selector to show all the time, though my version of Zen is a bit ahead of what’s published. The old version, I think, has bugs that will surely litter the console with error messages. I started preparing a new release a week or so back but have since been distracted by work.[/quote]

    It would be really great if a future release could resolve this problem.

    Otherwise the Zen coding plugin is really great and I am very grateful that you set aside your own time to create and maintain it. Many thanks.

    0 Likes

    #6

    I thought this fixed in OSX, but I was wrong.

    0 Likes

    Issue with auto complete
    #7

    I was having the same issue. Went into Packages/HTML/html_completions.py (ln 52) and removed the opening bracket from the following lines and it cleared up the issue. Hope this helps!

            if op == '.':
                snippet = "<{0} class=\"{1}\">$1</{0}>$0".format(tag, arg)
            else:
                snippet = "<{0} id=\"{1}\">$1</{0}>$0".format(tag, arg)
    0 Likes

    #8

    I’ve created an Issue on Sublimator’s github repo https://github.com/sublimator/ZenCoding/issues/8 about this, as I didn’t see any mention of it.

    0 Likes

    #9

    Thanks peruvianidol, but that doesn’t seem to solve my problem. I deleted the < on those two lines but it still auto-completes with it in there. Any other places I should change code?

    0 Likes