Skip to content

Commit a1722a3

Browse files
Infer missing end mark on ranges (#118)
* Infer same line as mark when using past end of line * infere missing end mark for all selection types
1 parent d95a990 commit a1722a3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/inferFullTargets.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,19 @@ export function inferRangeEndTarget(
382382
prototypeTargets: Target[],
383383
actionPreferences: ActionPreferences
384384
): PrimitiveTarget {
385+
const possiblePrototypeTargetsIncludingStartTarget = (
386+
[startTarget] as Target[]
387+
).concat(prototypeTargets);
385388
const prototypeTargetsIncludingStartTarget = hasContent(target)
386389
? []
387-
: ([startTarget] as Target[]).concat(prototypeTargets);
390+
: possiblePrototypeTargetsIncludingStartTarget;
388391

389392
const mark =
390393
target.mark ??
391-
extractAttributeFromList(prototypeTargetsIncludingStartTarget, "mark") ??
394+
extractAttributeFromList(
395+
possiblePrototypeTargetsIncludingStartTarget,
396+
"mark"
397+
) ??
392398
CURSOR_MARK;
393399

394400
const selectionType =
@@ -403,8 +409,7 @@ export function inferRangeEndTarget(
403409
// we don't want to blindly inherit modifier from startTarget. In
404410
// particular, we only want to inherit symbolType
405411
const modifier =
406-
target.modifier ??
407-
inferRangeEndModifier(startTarget, prototypeTargets);
412+
target.modifier ?? inferRangeEndModifier(startTarget, prototypeTargets);
408413

409414
const position: Position =
410415
target.position ??

src/test/suite/inferFullTargets.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ suite("inferFullTargets", () => {
77
fixture.forEach(({ input, expectedOutput }, index) => {
88
test(`inferFullTargets ${index}`, () => {
99
assert.deepStrictEqual(
10-
expectedOutput,
1110
inferFullTargets(
1211
input.context,
1312
input.partialTargets,
1413
input.actionPreferences
15-
)
14+
),
15+
expectedOutput
1616
);
1717
});
1818
});

0 commit comments

Comments
 (0)