Skip to content

Fix renaming with . in JSX tags#50373

Merged
probably-neb merged 3 commits intozed-industries:mainfrom
OmChillure:fix-renaming-html-dots-not-support-dots
Mar 2, 2026
Merged

Fix renaming with . in JSX tags#50373
probably-neb merged 3 commits intozed-industries:mainfrom
OmChillure:fix-renaming-html-dots-not-support-dots

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

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.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 28, 2026
@maxdeviant maxdeviant changed the title Fix renaming html dots not support dots Fix renaming with . in JSX tags Feb 28, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 344a302

@probably-neb
Copy link
Copy Markdown
Collaborator

Looks good! Thanks for the fix!

@probably-neb probably-neb merged commit 3630ac9 into zed-industries:main Mar 2, 2026
31 checks passed
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
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.
@smitbarmase
Copy link
Copy Markdown
Member

@OmChillure shouldn't we handle this at language level instead of hardcoding is_dot?

@OmChillure
Copy link
Copy Markdown
Contributor Author

OmChillure commented Mar 10, 2026

Hey @smitbarmase good point! I already investigated the language-level approach before this hardcoded stuff.

  • overrides.default in the language config : already tried (it was there in config.toml akready, but it doesn't work because the tree-sitter scope context at the tag-name cursor position doesn't match the default override at runtime.

  • Top-level : also tried moving it to the top level of the config, but still doesn't fix the issue for the same reason linked_edit_characters only feeds into the is_word check via the scope's char classifier, and the scope resolution at that position doesn't surface it.

The root cause is that when the cursor is inside a JSX tag name, no scope override is active, so neither approach makes . reach [is_word_char] hardcode in the shared linked-edit path is the only reliable fix without larger refactoring of how scope context is resolved for tag names.

Open to suggestions if there's a cleaner path I'm missing!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renaming HTML tags not supporting dots

4 participants