microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.82k stars 29.49k forks source link

[html] `editor.linkedEditing` does not work when the tag contains `.` #233262

Open dyc3 opened 3 weeks ago

dyc3 commented 3 weeks ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Take the following sample HTML and paste it in a blank HTML file
    <Table.Header>
    <Table.Row>
        <Table.Cell>Item</Table.Cell>
        <Table.Cell>Amount</Table.Cell>
    </Table.Row>
    </Table.Header>
  2. Enable editor.linkedEditing
  3. Attempt to edit Table.Row in the start or end tag
  4. See that the matching tag does not get edited

I am willing to contribute a fix for this. If I could get a code pointer or two, that would be great. I think I've found the unit test file for the feature, but I haven't found where it's actually implemented yet.

vs-code-engineering[bot] commented 3 weeks ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.95.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

dyc3 commented 3 weeks ago

For the record, I was able to reproduce this on main on my machine.

aeschli commented 3 weeks ago

Note that dots are not valid in HTML tag names: https://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-tag-name

So technically you are not editing HTML but a HTML-like templating language. Of course it's ok to use the HTML editor for that, but it will have limitations, as seen with this issue.

vs-code-engineering[bot] commented 3 weeks ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

dyc3 commented 2 weeks ago

You're right, the original snippet comes from a svelte codebase, and you're also right about HTML tag names only accepting alphanumeric characters. I've found that the wordPattern field in this language-configuration.json affects this feature, as removing the . from the regex fixes the issue I'm having.

I'm assuming that the svelte extension has some similar definition. Given that this isn't technically valid html, I'll forego making a PR here in favor of fixing the extension instead.