-
Notifications
You must be signed in to change notification settings - Fork 0
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
Move reference creation out of nodeMap #7
Conversation
clientId, | ||
); | ||
const { segment: endSeg } = this.getContainingSegment( | ||
normalizedEndPos - 1, |
There was a problem hiding this comment.
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
The test that is failing passed previously, so we should keep it working, as something must be different with this implementation. |
Co-authored-by: Tony Murphy <[email protected]>
@@ -1928,6 +1928,41 @@ export class MergeTree { | |||
localSeq, | |||
segmentGroup: undefined, | |||
}; | |||
const normalizedStartPos = startPos === "start" || startPos === undefined ? 0 : startPos; |
There was a problem hiding this comment.
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'
?
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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 },
);
This reverts commit 5cdcb37.
4ab2a18
into
anthony-murphy:LocalReferenceObliterate
Tests not passing: