Skip to content

Fix nested edits in SyntaxEditor#22269

Open
Shourya742 wants to merge 3 commits intorust-lang:masterfrom
Shourya742:2026-05-04-fix-nested-edits
Open

Fix nested edits in SyntaxEditor#22269
Shourya742 wants to merge 3 commits intorust-lang:masterfrom
Shourya742:2026-05-04-fix-nested-edits

Conversation

@Shourya742
Copy link
Copy Markdown
Member

part of #15710 and #18285

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 4, 2026
@Shourya742 Shourya742 requested a review from ChayimFriedman2 May 4, 2026 12:53
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just one nit.

View changes since this review

Comment on lines +114 to +117
.rev()
.position(|ancestor| ancestor.affected_range().contains_range(change.target_range()))
{
let index = changed_ancestors.len() - 1 - index;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.rev()
.position(|ancestor| ancestor.affected_range().contains_range(change.target_range()))
{
let index = changed_ancestors.len() - 1 - index;
.enumerate()
.rev()
.find(|ancestor| ancestor.affected_range().contains_range(change.target_range()))
{

Clearer this way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used rposition, since we can’t use the ancestor from enumerate directly, we need a mutable reference to changed_ancestors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants