Skip to content

[html] can't "rename symbol" within <script> tags #85411

Closed

Description

@ultraGentle

Problem
In an HTML file with <script> tags, the "rename symbol" command is unavailable.
VSCode 1.40.1

Workaround
"find and replace," but that's always a bit scarier, because it requires vigilance to avoid renaming the wrong thing.

Example
<p>catalog</p>
<script>
let cat = 'hiss';
cat = 'purr';
</script>

Desired behavior:
select cat --> rename symbol to "feline" --> should just replace the variable cat with feline, leaving "catalog" alone.

But, this option is unavailable.

So, the alternative is to find-and-replace all --> "cat" to "feline" --> "felinealog".
Or need to go one-by-one and check, which can be tricky in a long file.
Of course, you can be clever searching for " cat " with spaces, but this is just a simple example.

Possible solutions
In an HTML file, the rename could either affect all so-named symbols in all <script> tags in the file, or local to the current <script> tag.

Thanks for considering this!

Activity

  1. ultraGentle commented on Nov 22, 2019

    @ultraGentle
    ContributorAuthor

    I'm wondering if the cause of this is related to #85306, "Expand selection" misses { } in <script> tag, in which case perhaps both individual issues should be closed in favor of something like, "some editor features do not work within <script> tags."

  2. aeschli commented on Nov 26, 2019

    @aeschli
    Contributor

    It's just not implemented yet.

  3. added
    feature-request
    html
    on Nov 26, 2019
  4. changed the title [-]can't "rename symbol" within <script> tags[/-] [+][html] can't "rename symbol" within <script> tags[/+] on Nov 26, 2019
  5. ultraGentle commented on Nov 26, 2019

    @ultraGentle
    ContributorAuthor

    Thanks for the response. Good to know.

  6. stagefright5 commented on May 18, 2020

    @stagefright5

    Hey Martin Aeschlimann (@aeschli) , Can you provide any details on this? Is it in the roadmap?

  7. aeschli commented on May 18, 2020

    @aeschli
    Contributor

    No, it's not on the roadmap. Help is welcome!

  8. added
    help wanted
    on May 18, 2020
  9. chenjigeng commented on Dec 1, 2020

    @chenjigeng
    Contributor

    Martin Aeschlimann (@aeschli) can you check this? I did it by borrowing its ideas

  10. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Dec 9, 2020
  11. locked and limited conversation to collaborators on Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesthelp wantedhtmlinsiders-releasedverified

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions