Skip to content

internal: fix incorrect offset on multiple indel#22221

Merged
ChayimFriedman2 merged 2 commits intorust-lang:masterfrom
A4-Tacks:edit-offset-internal
Apr 30, 2026
Merged

internal: fix incorrect offset on multiple indel#22221
ChayimFriedman2 merged 2 commits intorust-lang:masterfrom
A4-Tacks:edit-offset-internal

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 30, 2026
for indel in &self.indels {
if indel.delete.start() >= offset {
break;
continue;
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 Apr 30, 2026

Choose a reason for hiding this comment

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

This looks correct to me; this function should return the new location of offset. if indel.delete.start() >= offset, it means we've already passed it so we should return what we've accumulated.

OTOH the return None in the next branch looks incorrect to me - it'll lead to early-exit when we shouldn't just because the next indel doesn't came yet. It should be if indel.delete.contains(offset).

View changes since the review

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.

This is actually this:

if indel.delete.start() < offset {
    if offset < indel.delete.end() {
        return None; // indel.delete.start() < offset && offset < indel.delete.end()
    }
    res += TextSize::of(&indel.insert);
    res -= indel.delete.len();
}

But I agree that the readability is very low

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.

Right, I got confused.

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Apr 30, 2026
Merged via the queue into rust-lang:master with commit 692043f Apr 30, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 30, 2026
@A4-Tacks A4-Tacks deleted the edit-offset-internal branch May 1, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants