Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mjbvz opened this issue Oct 31, 2018 · 4 comments · Fixed by #36490
Closed

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

mjbvz opened this issue Oct 31, 2018 · 4 comments · Fixed by #36490
Assignees
Labels
Committed The team has roadmapped this issue Domain: Refactorings e.g. extract to constant or function, rename symbol Domain: TSServer Issues related to the TSServer Suggestion An idea for TypeScript VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 31, 2018

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

@weswigham weswigham added Suggestion An idea for TypeScript Committed The team has roadmapped this issue Domain: TSServer Issues related to the TSServer labels Nov 1, 2018
@mjbvz mjbvz added the VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone label Oct 17, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.8.0 milestone Oct 31, 2019
@DanielRosenwasser DanielRosenwasser added the Domain: Refactorings e.g. extract to constant or function, rename symbol label Jan 24, 2020
@DanielRosenwasser
Copy link
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.

@RyanCavanaugh
Copy link
Member

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

@DanielRosenwasser
Copy link
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).

@rbuckton
Copy link
Contributor

@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
Labels
Committed The team has roadmapped this issue Domain: Refactorings e.g. extract to constant or function, rename symbol Domain: TSServer Issues related to the TSServer Suggestion An idea for TypeScript VS Code Priority Critical issues that VS Code needs fixed in the current TypeScript milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants