Skip to content

7.0 regression: prepareRename placeholder includes quotes and bracketsΒ #65444

Open

Description

@mizdra

πŸ”Ž Search Terms

"prepareRename", "rename", "placeholder", "quotes", "brackets"

πŸ•— Version & Regression Information

  • This changed between versions 6.0.3 and 7.0.2

⏯ Playground Link

https://www.typescriptlang.org/play/v2/#code/v2/N4IghgxgLglgbgUwGIwDYJALhAegO4D2ATgNYDOADpAjmURDjAHYAmCAHgHRRkgA0IAGZoEvTKHzFyVCDR4QCTYQHNOAKzKKsIYAB0mAAgO6QCgLYURRAPIVYisicwG9ho8ZBmCLAK7onHkzeCEwcUCZ8+u4eUGBEygjhWB6ioexJkW5GJmRQRDDQAXk+CJnRJkEAqkwQABYIECQILACSrBzNAIIQsmSOycWlUe4mHJBQtvZMYKgACkQEFAhEUACeACqrS-3Og2Ujnt5+CAAiiQ1TASaCxLIRw9kgbBCocWCXA0Ql+49kJDAUAAyMAARgBheqNIpfBDDAC++xMzBePjYAQA2iZOLR6DgAFR4-EmAC6+jh+n4uEIpEo1BxDGYbC4PG0CiYuQMBBBagMAF4XMMwM4AIz7ADkILFIv26LFEDFxOlZIA3Pp9Fy1JwwKqgtzZWAFTqNZwQUbuZwIDqQAiQGQEOhoDAtOIQBQCGQYFMwQRUD4zEwsABWARuj1TYGhAByfpByywAE4BHaHVMAMqxFbe33+oNJ+0XJ1MdNxKARhDRsyxogJm2IIge50AJjhQA

πŸ’» Code

const obj = {
  a: 1,
  'b': 1,
  ['c']: 1,
};

obj.a;
obj['a'];
obj.b;
obj.c;

πŸ™ Actual behavior

Pressing F2 on each property name prefills the rename input as follows:

Position 7.1.0-dev.20261111.1
obj.a a
obj['a'] a
obj.b 'b'
obj.c ['c']

Changing 'b' to 'b1' in the input at obj.b produces ''b1'': 1, and obj.'b1';. As a result, the code ends up with invalid syntax.

2026-11-12.1.21.45.mov

πŸ™‚ Expected behavior

The initial value of the rename input should be the same as in 6.0.3, which is as follows:

Position 6.0.3
obj.a a
obj['a'] a
obj.b b
obj.c c

Users would expect the input to be prefilled with the text at the position where they requested the rename.

Additional information about the issue

Sending textDocument/prepareRename at b in obj.b ({ "line": 8, "character": 4 }) to the language server returns the following response:

{
  "range": {
    "start": { "line": 8, "character": 4 },
    "end": { "line": 8, "character": 5 }
  },
  "placeholder": "'b'"
}

range covers only b without the quotes, but placeholder is 'b' with the quotes.

The LSP specification defines the result of prepareRename as Range | { range: Range, placeholder: string } | { defaultBehavior: boolean } | null, where placeholder is "a placeholder text of the string content to be renamed" (specification). VS Code prefills the input with placeholder if it is given, or with the text in range otherwise (source). Therefore, the input is prefilled with 'b' at obj.b.

In my opinion, placeholder in the prepareRename response should be a string without quotes or brackets. That is, the response above should have "placeholder": "b".

Activity

  1. changed the title [-]7.0 regression: `prepareRename` placeholder includes quotes and brackets (e.g. `'b'`, `['c']`)[/-] [+]7.0 regression: `prepareRename` placeholder includes quotes and brackets[/+] on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbol

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 捒网址