angular icon indicating copy to clipboard operation
angular copied to clipboard

[Feature request] Highlighting within inline templates

Open christophbuehler opened this issue 1 year ago β€’ 6 comments

πŸš€ feature request

Description

When the cursor is placed on any tag within an inline template, the entire template is highlighted. In external HTML templates, just the opening and the closing tag are highlighted. I assume this is the case because the language mode of the file is set to TypeScript, not HTML. I find this very annoying.

Feature Type

What does this bug affect

  • [x] Angular Language Service VSCode extension
  • [ ] Angular Language Service server

Describe the solution you'd like

Ideally the language mode of inline templates would be set to HTML.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?

I have tried using other extensions, like Inline HTML that should change the language mode of template strings with moderate success.

Anything else relevant?

How it is: image What I would expect: image

christophbuehler avatar Aug 11 '24 20:08 christophbuehler

As a temporary workaround you can set the following in your settings.json

"workbench.colorCustomizations": {
    "editor.wordHighlightBackground": "#ffffff00",
    "minimap.selectionOccurrenceHighlight": "#ffffff00"
}

urielzen avatar Feb 09 '25 19:02 urielzen

This drives me insane, makes inline templates almost unusable.

You can sorta get around this by disabling Editor: Occurrences Highlight in the settings. The downside is that you miss out on occurrences highlighting (clicking on a symbol and seeing other instances of it highlighted).

It looks like this was actually a previous problem that was fixed at some point: https://github.com/microsoft/vscode/issues/185267 https://github.com/microsoft/TypeScript/pull/46531

So it's possible this is a TypeScript issue and not Angular.

jreidgreer avatar Feb 26 '25 22:02 jreidgreer

This does seem like its due to the Occurrences Highlight feature. The language service already switches the language inside the template string to html and isn't actively providing a highlight for the whole string. It does seem like there's a potential regression in VSCode. The test added in https://github.com/microsoft/TypeScript/pull/46531 to verify the multiline template string didn't highlight is now verifying baseline highlights at head

atscott avatar Feb 27 '25 17:02 atscott

Appreciate you looking into this @atscott! I'll go ahead and open an issue in the TypeScript repo.

jreidgreer avatar Feb 28 '25 06:02 jreidgreer

I noticed this happens in lazyvim too

cyb456 avatar Sep 26 '25 21:09 cyb456

FYI the bug I opened on this in the TS repo has been closed because of the stop in development of the TS-based language service.

The good news is this bug is fixed in the native preview!: https://marketplace.visualstudio.com/items?itemName=TypeScriptTeam.native-preview

jreidgreer avatar Dec 03 '25 19:12 jreidgreer