Skip to content

Check whether marker is removed in searchForMarker #24771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dds/merge-tree/src/mergeTree.ts
Original file line number Diff line number Diff line change
@@ -1270,7 +1270,7 @@ export class MergeTree {
segment,
(node) => {
if (node.isLeaf()) {
Copy link
Preview

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

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

Introducing the !isRemoved(node) condition prevents removed markers from being returned. Consider adding a short inline comment describing why this check is necessary for future maintainability.

Suggested change
if (node.isLeaf()) {
if (node.isLeaf()) {
// Exclude removed markers to ensure only valid markers are returned.

Copilot uses AI. Check for mistakes.

if (Marker.is(node) && refHasTileLabel(node, markerLabel)) {
if (!isRemoved(node) && Marker.is(node) && refHasTileLabel(node, markerLabel)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we need the same check where we update leftmostTiles and rightmostTiles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leftmostTiles and rightmostTiles already exclude removed tiles due to the check for (this.leafLength(segment) ?? 0) > 0

foundMarker = node;
}
} else {
Original file line number Diff line number Diff line change
@@ -596,14 +596,14 @@ describe("TestClient", () => {

it("Should return undefined when trying to find a removed marker", () => {
client.insertTextLocal(0, "abc");
client.insertMarkerLocal(0, ReferenceType.Tile, {
client.insertMarkerLocal(1, ReferenceType.Tile, {
[reservedMarkerIdKey]: "marker",
[reservedTileLabelsKey]: ["Eop"],
});

assert.equal(client.getLength(), 4, "length not expected");

client.removeRangeLocal(0, 1);
client.removeRangeLocal(1, 2);

assert.equal(client.getLength(), 3, "length not expected");

Loading
Oops, something went wrong.