Skip to content

Commit

Permalink
add position handling (verify existing tests work)
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Sep 19, 2024
1 parent 358ba02 commit c5622be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
37 changes: 29 additions & 8 deletions src/web/unitMotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,16 @@ export function registerUnitMotions(context: vscode.ExtensionContext) {
}
}

enum RangePosition {
First,
Middle,
Last,
}

interface Range {
start?: vscode.Position;
end?: vscode.Position;
position?: RangePosition;
}

function* singleLineUnitsForDoc(
Expand Down Expand Up @@ -219,12 +226,18 @@ function* unitsForDoc(
forward: boolean
): Generator<Range> {
// 'units' to denote the start/end of a document (avoids edge cases downstream)
const first = new vscode.Position(0, 0);
const startUnit = {
end: new vscode.Position(0, 0),
start: first,
end: first,
position: RangePosition.First,
};

const last = lastPosition(doc);
const endUnit = {
start: lastPosition(doc),
start: last,
end: last,
position: RangePosition.Last,
};

if (unit instanceof RegExp) {
Expand Down Expand Up @@ -403,9 +416,9 @@ function toBoundary(args: {boundary?: string}) {
}

function fuseRanges(a: Range, b: Range): Range {
if (!a?.start && !b?.end) {
if (!a?.start) {
return {start: b?.start, end: a?.end};
} else if (!b?.start && !a?.end) {
} else if (!a?.end) {
return {start: a?.start, end: b?.end};
} else {
return a;
Expand Down Expand Up @@ -435,7 +448,9 @@ function* resolveUnitBoundaries(
back = moreBack;
}
}
yield back;
if (back.position !== RangePosition.First) {
yield back;
}
yield firstUnit;
} else {
if (!back?.start) {
Expand All @@ -445,7 +460,9 @@ function* resolveUnitBoundaries(
back = moreBack;
}
}
yield back;
if (back.position !== RangePosition.First) {
yield back;
}
yield firstUnit;
}
} else if (resolve === Boundary.End && (!firstUnit?.end || forward)) {
Expand All @@ -457,7 +474,9 @@ function* resolveUnitBoundaries(
back = moreBack;
}
}
yield back;
if (back.position !== RangePosition.Last) {
yield back;
}
yield firstUnit;
} else {
if (!back?.end) {
Expand All @@ -467,7 +486,9 @@ function* resolveUnitBoundaries(
back = moreBack;
}
}
yield back;
if (back.position !== RangePosition.Last) {
yield back;
}
yield firstUnit;
}
} else if (resolve === Boundary.Both && (!firstUnit?.start || !firstUnit?.end)) {
Expand Down
3 changes: 2 additions & 1 deletion wdio.conf.mts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export const config: Options.Testrunner = {
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
logLevel: process.env.COVERAGE ? 'warn' : 'info',

//
// Set specific log levels per logger
// loggers:
Expand Down

0 comments on commit c5622be

Please sign in to comment.