microsoft / vscode-htmltagwrap

Wraps a chunk of HTML code in tags
Other
24 stars 18 forks source link

BUG: VSCode autoclose for HTML causing wrap to occur twice #15

Open GitLiamuk opened 7 years ago

GitLiamuk commented 7 years ago

VSCode version: 1.16.0 adds a html autoclose feature.

This feature causes this extension to wrap the selected text prematurely, resulting in faulty markup.

dimkir commented 7 years ago

The "inner" </p> is added by autoclose.. image

bennyschaefer commented 7 years ago

htmltagwrap hasn't seen an update in about a year. I doubt we'll see a fix for this. But I did some testing and came up with this solution that works:

VSCode can do htmltagwrap without the extension. Here's how:

  1. Disable or remove the htmltagwrap extension
  2. File > Preferences > Keyboard Shortcuts
  3. Search for 'emmet wrap'
  4. Set Keybinding for 'Wrap Individual Lines with Abbreviation' to Alt + W (or whatever you desire)

There you go. The only difference is that you get to enter the desired tag instead of automatically getting a p-tag.

PS: I know this doesn't really contribute to a bugfix, but since there hasn't been any work on this extension in a while, and I really grew fond of its functionality (as did others), I felt comfortable sharing this workaround here in case anyone else misses the ease of adding tags to a selection.

PPS: I'm aware this kinda misuses the emmet wrap feature, but it still works. Definitely better than having to remove an auto-closed tag each time.

bgashler1 commented 7 years ago

This bug is the result of a breaking change from the autoclose feature discussed in https://github.com/Microsoft/vscode/issues/2246#issuecomment-325475022. I'm looking into fixing this (and also on accepting the pull requests that have been sitting here for a while). Apologies for the neglect to this extension. I want to fix it up and deliver on the top requests. Thanks for your patience!

bgashler1 commented 7 years ago

In the meantime, a workaround is using the setting

    "html.autoClosingTags": false

which will prevent the duplicate tag.

dreadsoul commented 7 years ago

I have also the same problem and think the following details will be useful:

  1. if I do select a word then i get: <p></p>Lorem.</p>
  2. if i do just Alt+W i have: </p><p>

Note: If I select more then 1 line the problem does not occur!

bgashler1 commented 6 years ago

This issue was moved to bgashler1/vscode-htmltagwrap#1