Skip to content

Allow class/function rename to be triggered on declaration keywords and modifiers #28268

Closed

Description

@mjbvz

Search Terms

  • rename

Suggestion

Follow up on microsoft/vscode#58907

Allow renames to be triggered on keywords such as public, private, class, const, readonly, and function to rename the symbol itself

class Foo {
    public bar() { }
}

function func() { }

const x = 1;

Use the triggerSpan property on the renameResponse to actually trigger the rename on the symbol.

We currently return "You cannot rename this element." for these cases

Activity

  1. DanielRosenwasser commented on Jan 24, 2020

    @DanielRosenwasser
    Member

    Word of caution to make sure that this doesn't interfere with document highlights. Today, if you're hovering on

    class C {
      /**/public foo;
      public bar;
    }

    we highlight all occurrences of the public keyword within C.

  2. RyanCavanaugh commented on Jan 24, 2020

    @RyanCavanaugh
    Member

    Daniel Rosenwasser (@DanielRosenwasser) is that a bug or a feature? The current behavior re: public seems useless

  3. DanielRosenwasser commented on Jan 25, 2020

    @DanielRosenwasser
    Member

    That's a feature - document highlights aims to make it easy to scan through relevant/related declarations and constructs (e.g. the switch/case/break keywords and every export-ed declaration). I don't see this as any different.

    It's also more consistent with the rest of the editor's visual cues (e.g. the way that VS Code highlights all occurrences of a word in a plain text buffer works more similarly to how we highlight the export keyword than find-all-references).

  4. rbuckton commented on Jan 30, 2020

    @rbuckton
    Contributor

    Daniel Rosenwasser (@DanielRosenwasser): We currently highlight occurrences of the class or function name when you put the cursor on class or function. Should we change that to highlight occurrences of the class/function keyword instead to align with that behavior? We currently don't highlight occurrences of keywords like interface, type, enum, module, or namespace today either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueDomain: LS: Refactoringse.g. extract to constant or function, rename symbolDomain: LS: TSServerIssues related to the TSServerSuggestionAn idea for TypeScriptVS Code PriorityCritical issues that VS Code needs fixed in the current TypeScript milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions