editor: Treat blank rename as no-op - #62630
Conversation
|
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 |
|
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. |
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
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: