* 👷 CI for jetbrains * default working dir * changelog * build binaries * binary testing setup * idesettings * core binary testing * run binary tests in ci * remove unused targets * needs build * console.log bin contents * fix ci * fix win32 binary download * test * no linux arm64 * macos latest * macos-12 * binary permissions * upload logs * fix * upload full folder as binary artifact * test * test macos only * set full execute permissions * copy sqlite binary * cd * it worked! * build again in test job * debug * remove timeout * info * log * log2 * more logs * catch * fewer logs * test all platforms * test downloaded artifact * needs build * updates * build * false * release * add tag and upload binaryes * change tag name * proper artifact upload * jest updates * ✅ generate a few unit tests with Continue * fix imports related to IdeSettings * run tsc on PRs * remove shareSession command (unused) * update release process * update plugin version * don't show ghost text when jetbrains completion visible * run jetbrains ci in main
123 lines
2.8 KiB
TypeScript
123 lines
2.8 KiB
TypeScript
// This file is generated by Continue
|
|
|
|
import { intersection } from "../../../util/ranges";
|
|
|
|
interface Position {
|
|
line: number;
|
|
character: number;
|
|
}
|
|
|
|
interface Range {
|
|
start: Position;
|
|
end: Position;
|
|
}
|
|
|
|
describe("intersection", () => {
|
|
let rangeA: Range;
|
|
let rangeB: Range;
|
|
|
|
beforeEach(() => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 3, character: 5 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 2, character: 2 },
|
|
end: { line: 4, character: 0 },
|
|
};
|
|
});
|
|
|
|
test("returns correct intersection for overlapping ranges", () => {
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toEqual({
|
|
start: { line: 2, character: 2 },
|
|
end: { line: 3, character: 5 },
|
|
});
|
|
});
|
|
|
|
test("returns null for non-overlapping ranges", () => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 2, character: 0 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 3, character: 0 },
|
|
end: { line: 4, character: 0 },
|
|
};
|
|
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
// TODO
|
|
test.skip("returns correct intersection for single line overlap", () => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 1, character: 5 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 1, character: 3 },
|
|
end: { line: 2, character: 0 },
|
|
};
|
|
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toEqual({
|
|
start: { line: 1, character: 3 },
|
|
end: { line: 1, character: 5 },
|
|
});
|
|
});
|
|
|
|
test("returns null for single line non-overlapping ranges", () => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 1, character: 2 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 1, character: 3 },
|
|
end: { line: 1, character: 5 },
|
|
};
|
|
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
test("returns correct intersection when one range is fully within another", () => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 4, character: 5 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 2, character: 2 },
|
|
end: { line: 3, character: 3 },
|
|
};
|
|
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toEqual({
|
|
start: { line: 2, character: 2 },
|
|
end: { line: 3, character: 3 },
|
|
});
|
|
});
|
|
|
|
test("returns correct intersection when ranges touch at the edge", () => {
|
|
rangeA = {
|
|
start: { line: 1, character: 0 },
|
|
end: { line: 2, character: 0 },
|
|
};
|
|
|
|
rangeB = {
|
|
start: { line: 2, character: 0 },
|
|
end: { line: 3, character: 0 },
|
|
};
|
|
|
|
const result = intersection(rangeA, rangeB);
|
|
expect(result).toEqual({
|
|
start: { line: 2, character: 0 },
|
|
end: { line: 2, character: 0 },
|
|
});
|
|
});
|
|
});
|