Filter out zero-width selections

This commit is contained in:
Andrew Branch
2019-04-19 09:44:42 -07:00
parent 6177596c27
commit f0a3d2bf92
2 changed files with 39 additions and 5 deletions

View File

@@ -70,10 +70,13 @@ namespace ts.SmartSelectionRange {
return selectionRange;
function pushSelectionRange(start: number, end: number): void {
// Skip ranges that are identical to the parent
const textSpan = createTextSpanFromBounds(start, end);
if (!selectionRange || !textSpansEqual(textSpan, selectionRange.textSpan)) {
selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
// Skip empty ranges
if (start !== end) {
// Skip ranges that are identical to the parent
const textSpan = createTextSpanFromBounds(start, end);
if (!selectionRange || !textSpansEqual(textSpan, selectionRange.textSpan)) {
selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
}
}
}
}