Fix renaming with . in JSX tags#50373
Conversation
. in JSX tags
|
Looks good! Thanks for the fix! |
Fixes zed-industries#50245 ### Summary : This PR fixes linked tag renaming when typing . in tag names like <Table.Headers>...</Table.Headers>. Previously, linked editing treated . as punctuation (unless a language explicitly configured it as a linked-edit character), so renaming could stop syncing at the dot and produce mismatched closing tags. ### What changed Updated linked-edit input handling to preserve linked edits when the typed input is exactly ".", even if the active language does not explicitly include dot in linked_edit_characters. Added a regression test covering dot typing in linked edits without language override. Kept existing punctuation behavior (e.g. >) unchanged. ### Files changed [editor.rs] [editor_tests.rs] ### Why this approach Minimal, targeted fix in shared linked-edit path. Works for .svelte and similar markup contexts where dot-separated component names are valid in practice. Avoids requiring every language/extension to add dot config individually. ### Validation Manual repro confirmed: opening tag rename with dot now keeps closing tag synced. Added test: test_linked_edits_on_typing_dot_without_language_override. Existing related test remains relevant: test_linked_edits_on_typing_punctuation.
|
@OmChillure shouldn't we handle this at language level instead of hardcoding |
|
Hey @smitbarmase good point! I already investigated the language-level approach before this hardcoded stuff.
The root cause is that when the cursor is inside a JSX tag name, no scope override is active, so neither approach makes . reach Open to suggestions if there's a cleaner path I'm missing! |
Fixes #50245
Summary :
This PR fixes linked tag renaming when typing . in tag names like <Table.Headers>...</Table.Headers>.
Previously, linked editing treated . as punctuation (unless a language explicitly configured it as a linked-edit character), so renaming could stop syncing at the dot and produce mismatched closing tags.
What changed
Updated linked-edit input handling to preserve linked edits when the typed input is exactly ".", even if the active language does not explicitly include dot in linked_edit_characters.
Added a regression test covering dot typing in linked edits without language override.
Kept existing punctuation behavior (e.g. >) unchanged.
Files changed
[editor.rs]
[editor_tests.rs]
Why this approach
Minimal, targeted fix in shared linked-edit path.
Works for .svelte and similar markup contexts where dot-separated component names are valid in practice.
Avoids requiring every language/extension to add dot config individually.
Validation
Manual repro confirmed: opening tag rename with dot now keeps closing tag synced.
Added test: test_linked_edits_on_typing_dot_without_language_override.
Existing related test remains relevant: test_linked_edits_on_typing_punctuation.