Skip to content

Use the symbol name for the rename placeholder - #65535

Closed
Josué Barros (joshbarros) wants to merge 2 commits into
microsoft:mainfrom
joshbarros:fix/65444-prepare-rename-placeholder
Closed

Josué Barros (joshbarros) wants to merge 2 commits into
microsoft:mainfrom
joshbarros:fix/65444-prepare-rename-placeholder

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #65444

getRenameInfoForNode passed SymbolToString as the rename placeholder. For a property declared with a quoted or computed name, SymbolToString prints the declaration form, so prepareRename prefilled 'b' or ['c'] instead of b or c. The classic implementation uses the symbol name, which is already unquoted. The trigger range was already correct and is unchanged.

The new TestPrepareRenamePlaceholderForQuotedProperties covers obj.a, obj['a'], obj.b and obj.c. On the unfixed server the last two placeholders are 'b' and ['c'].

Validation:

  • go test ./tsc/internal/lsp -run TestPrepareRenamePlaceholderForQuotedProperties -count=1: fails without the change, passes with it.
  • go test ./tsc/internal/ls ./tsc/internal/lsp -count=1: pass.
  • go test ./tsc/internal/fourslash/tests -run 'Rename' -count=1: pass.
  • gofmt: clean.

Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.

getRenameInfoForNode passed SymbolToString to the rename placeholder. For a property declared with a quoted or computed name, SymbolToString prints the declaration form, so prepareRename prefilled 'b' or ['c'] instead of b or c. The classic implementation uses the symbol name, which is already unquoted. The trigger range was already correct and is unchanged.

Adds an LSP test for obj.a, obj['a'], obj.b and obj.c.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 18:53
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 16, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rename preparation for private identifiers prefills a class-specific internal key instead of the source name (e.g., #foo); use ast.SymbolName(symbol) and add an exact private-name placeholder assertion.

1 open issue
What changed in this PR

This PR addresses #65444 by using symbol names for language-server rename placeholders, removing declaration quotes and brackets while leaving trigger ranges unchanged.

Changes:

  • Replaces symbol stringification with the stored symbol name.
  • Adds an LSP regression test for ordinary, quoted, and computed property names.
File Description
tsc/​internal/​lsp/​server_rename_test.go Adds exact placeholder assertions for four property-access cases.
tsc/​internal/​ls/​rename.go Changes the name used in rename placeholders.

Review effort: Balanced

Comment thread tsc/internal/ls/rename.go Resolved
symbol.Name() returns the class-specific internal key for a private identifier, so preparing a rename on #x returned that key instead of #x. Use SymbolToString for private identifiers and keep the symbol name for the quoted and computed property fix.
@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7.0 regression: prepareRename placeholder includes quotes and brackets

3 participants