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
This commit is contained in:
Andreas Arvidsson 2021-07-21 02:34:25 +02:00 committed by GitHub
parent d95a990437
commit a1722a3853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -382,13 +382,19 @@ export function inferRangeEndTarget(
prototypeTargets: Target[],
actionPreferences: ActionPreferences
): PrimitiveTarget {
const possiblePrototypeTargetsIncludingStartTarget = (
[startTarget] as Target[]
).concat(prototypeTargets);
const prototypeTargetsIncludingStartTarget = hasContent(target)
? []
: ([startTarget] as Target[]).concat(prototypeTargets);
: possiblePrototypeTargetsIncludingStartTarget;
const mark =
target.mark ??
extractAttributeFromList(prototypeTargetsIncludingStartTarget, "mark") ??
extractAttributeFromList(
possiblePrototypeTargetsIncludingStartTarget,
"mark"
) ??
CURSOR_MARK;
const selectionType =
@ -403,8 +409,7 @@ export function inferRangeEndTarget(
// we don't want to blindly inherit modifier from startTarget. In
// particular, we only want to inherit symbolType
const modifier =
target.modifier ??
inferRangeEndModifier(startTarget, prototypeTargets);
target.modifier ?? inferRangeEndModifier(startTarget, prototypeTargets);
const position: Position =
target.position ??

View File

@ -7,12 +7,12 @@ suite("inferFullTargets", () => {
fixture.forEach(({ input, expectedOutput }, index) => {
test(`inferFullTargets ${index}`, () => {
assert.deepStrictEqual(
expectedOutput,
inferFullTargets(
input.context,
input.partialTargets,
input.actionPreferences
)
),
expectedOutput
);
});
});