mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-05 05:17:38 +03:00
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:
parent
d95a990437
commit
a1722a3853
@ -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 ??
|
||||
|
@ -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
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user