mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
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:
commit
a890275463
@ -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 don’t contain the original position
|
||||
textSpanIntersectsWithPosition(textSpan, pos)
|
||||
)) {
|
||||
selectionRange = { textSpan, ...selectionRange && { parent: selectionRange } };
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
const a = 'a';
|
||||
const b = /**/'b';
|
||||
|
||||
|
||||
'b'
|
||||
|
||||
const b = 'b';
|
||||
|
||||
const a = 'a';
|
||||
const b = 'b';
|
||||
6
tests/cases/fourslash/smartSelection_stringLiteral.ts
Normal file
6
tests/cases/fourslash/smartSelection_stringLiteral.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const a = 'a';
|
||||
//// const b = /**/'b';
|
||||
|
||||
verify.baselineSmartSelection();
|
||||
Loading…
x
Reference in New Issue
Block a user