Merge pull request #31912 from andrewbranch/bug/31657

Fix smartSelection returning extra span inside string quotes when cursor is outside them
This commit is contained in:
Andrew Branch
2019-07-01 11:53:24 -07:00
committed by GitHub
3 changed files with 22 additions and 2 deletions

View File

@@ -72,9 +72,13 @@ namespace ts.SmartSelectionRange {
function pushSelectionRange(start: number, end: number): void {
// 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)) {
if (!selectionRange || (
// Skip ranges that are identical to the parent
!textSpansEqual(textSpan, selectionRange.textSpan) &&
// Skip ranges that dont contain the original position
textSpanIntersectsWithPosition(textSpan, pos)
)) {
selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
}
}