Skip to content

Reduce duplicate code for TextChange overlaps#22278

Merged
1 commit merged into
masterfrom
overlap
Mar 2, 2018
Merged

Reduce duplicate code for TextChange overlaps#22278
1 commit merged into
masterfrom
overlap

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 1, 2018

These functions all compute the same thing in slightly different ways.

@ghost ghost requested a review from armanio123 March 1, 2018 23:01
Comment thread src/compiler/utilities.ts
if (intersectStart <= intersectEnd) {
return createTextSpanFromBounds(intersectStart, intersectEnd);
}
return undefined;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You haven't done any logic changes here. From what I can see, renamed the variables and re written the logic using ternary operator. Is there anything am missing here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, this PR isn't meant to change the return values of anything.

Comment thread src/compiler/utilities.ts
}
return undefined;
const overlap = textSpanIntersection(span1, span2);
return overlap && overlap.length === 0 ? undefined : overlap;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

here maybe consider doing return textSpanIntersection(span1, span2) as it returns undefined if no value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

textSpanIntersection doesn't return undefined if there's a 0-size intersection (the ranges are right up against each other), but this function does. So they're not exactly the same.

@ghost ghost merged commit b90cdb2 into master Mar 2, 2018
@ghost ghost deleted the overlap branch March 2, 2018 18:22
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants