Skip to content

editor: Treat blank rename as no-op - #62630

Merged
bennetbo merged 2 commits into
mainfrom
fix-empty-rename
Aug 14, 2026
Merged

editor: Treat blank rename as no-op#62630
bennetbo merged 2 commits into
mainfrom
fix-empty-rename

Conversation

@bennetbo

@bennetbo bennetbo commented Aug 14, 2026

Copy link
Copy Markdown
Member

Confirming an inline rename after deleting the entire symbol name or entering only whitespace currently submits an invalid rename request to the language server. This can remove the symbol text instead of leaving the source unchanged.

Treat empty and whitespace-only replacements as successful no-ops after dismissing the inline rename UI. Returning a completed task also consumes the confirmation action, preventing Enter from propagating back into the editor. Non-blank rename behavior remains unchanged.

The regression test covers both empty and whitespace-only rename fields, verifying that no LSP rename request is sent and the original buffer remains intact.

Release Notes:

  • editor: Fixed confirming a blank symbol LSP-rename modifying the source code

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 14, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Aug 14, 2026
@bennetbo bennetbo changed the title editor: Treat empty rename as no-op editor: Treat blank rename as no-op Aug 14, 2026
@bennetbo
bennetbo enabled auto-merge August 14, 2026 13:38
@bennetbo
bennetbo added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit 5fa8742 Aug 14, 2026
40 checks passed
@bennetbo
bennetbo deleted the fix-empty-rename branch August 14, 2026 13:56
@xdBronch

Copy link
Copy Markdown
Contributor

can i ask what the motivation was for this? i dont see anything in the LSP spec that says such a request is invalid and im aware of at least 2 languages that allow identifiers that are all whitespace. imo if a server is handling this poorly its on them to fix it. not that its likely to need to do this but i dont like seemingly arbitrary restrictions

@bennetbo

bennetbo commented Aug 15, 2026

Copy link
Copy Markdown
Member Author

We received some feedback that users kept accidentally renaming variables to an empty string, e.g. by accidentally hitting delete+return during a rename. Some language servers respond with an error (e.g. Rust Analyzer), but some just apply the rename (e.g. VSTLS). So, it made sense to guard against renaming to an empty string. Similar motivation for all whitespace renames: there might be languages out there which technically support it, but I'm not aware of any real world usage for renaming a symbol to all whitespace characters and it felt like more users will accidentally run into that case than someone actually renaming to all whitespace characters.

playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
Confirming an inline rename after deleting the entire symbol name or
entering only whitespace currently submits an invalid rename request to
the language server. This can remove the symbol text instead of leaving
the source unchanged.

Treat empty and whitespace-only replacements as successful no-ops after
dismissing the inline rename UI. Returning a completed task also
consumes the confirmation action, preventing Enter from propagating back
into the editor. Non-blank rename behavior remains unchanged.

The regression test covers both empty and whitespace-only rename fields,
verifying that no LSP rename request is sent and the original buffer
remains intact.

Release Notes:

- editor: Fixed confirming a blank symbol LSP-rename modifying the
source code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants