Skip to content
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

Move reference creation out of nodeMap #7

Merged

Conversation

jzaffiro
Copy link
Collaborator

Tests not passing:

  • obliterate.reconnect.spec.ts: "deletes concurrently inserted segment between group ops"

clientId,
);
const { segment: endSeg } = this.getContainingSegment(
normalizedEndPos - 1,
Copy link
Owner

Choose a reason for hiding this comment

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

maybe add an assert that normalizedEndPos is greater than zero

@anthony-murphy
Copy link
Owner

The test that is failing passed previously, so we should keep it working, as something must be different with this implementation.

@@ -1928,6 +1928,41 @@ export class MergeTree {
localSeq,
segmentGroup: undefined,
};
const normalizedStartPos = startPos === "start" || startPos === undefined ? 0 : startPos;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider the empty obliteration cases too. What's preventing startPos === 'end'?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I added the following function on my branch for this purpose:

/**
 * Returns the given place in InteriorSequencePlace form.
 */
export function normalizePlace(place: SequencePlace): InteriorSequencePlace {
	if (typeof place === "number") {
		return { pos: place, side: Side.Before };
	}
	if (place === "start") {
		return { pos: -1, side: Side.After };
	}
	if (place === "end") {
		return { pos: -1, side: Side.Before };
	}
	return place;
}

Copy link
Collaborator

@titrindl titrindl Sep 12, 2024

Choose a reason for hiding this comment

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

With an InteriorSequencePlace you can do the following:

const startPlace = normalizePlace(start);
const startSegment = this.getContainingSegment(startPlace.pos, refSeq, clientId).segment;
obliterate.start = this.createLocalReferencePosition(
	startSegment,
	startPlace.side === Side.Before ? 0 : startSegment?.cachedLength - 1,
	ReferenceType.StayOnRemove | ReferenceType.RangeBegin,
	{ obliterate },
);

@jzaffiro jzaffiro merged commit 4ab2a18 into anthony-murphy:LocalReferenceObliterate Sep 13, 2024
2 checks passed
@jzaffiro jzaffiro deleted the refCreationCleanup branch September 13, 2024 17:13
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