Skip to content

Commit df74c28

Browse files
Fix circular dependences
1 parent 10fa6d2 commit df74c28

17 files changed

Lines changed: 45 additions & 42 deletions

File tree

oxlint.config.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ export default defineConfig({
184184
extensions: [".tsx"],
185185
},
186186
],
187-
"import/no-cycle": "off",
188187
eqeqeq: [
189188
"warn",
190189
"always",

packages/lib-common/src/ide/inMemoryTextEditor/InMemoryTextEditor.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { URI } from "vscode-uri";
2+
import type { Edit } from "../../types/Edit";
3+
import type { GeneralizedRange } from "../../types/GeneralizedRange";
4+
import type { Range } from "../../types/Range";
5+
import type { RevealLineAt } from "../../types/RevealLineAt";
6+
import { Selection } from "../../types/Selection";
7+
import type { SelectionOffsets } from "../../types/Selection";
8+
import type { TextDocument } from "../../types/TextDocument";
29
import type {
3-
Edit,
410
EditableTextEditor,
5-
EmittableIDE,
6-
GeneralizedRange,
711
OpenLinkOptions,
8-
Range,
9-
RevealLineAt,
10-
SelectionOffsets,
1112
SetSelectionsOpts,
12-
TextDocument,
1313
TextEditor,
14-
TextEditorOptions,
15-
} from "@cursorless/lib-common";
16-
import { Selection, selectionsEqual } from "@cursorless/lib-common";
14+
} from "../../types/TextEditor";
15+
import type { TextEditorOptions } from "../../types/TextEditorOptions";
16+
import { selectionsEqual } from "../../util/selectionsEqual";
17+
import type { EmittableIDE } from "../types/ide.types";
1718
import { InMemoryTextDocument } from "./InMemoryTextDocument";
1819

1920
interface Params {

packages/lib-common/src/ide/types/RawTreeSitterQueryProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Disposable } from "@cursorless/lib-common";
1+
import type { Disposable } from "./ide.types";
22

33
/**
44
* Provides raw tree-sitter queries. These are usually read from `.scm` files

packages/lib-common/src/types/Position.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { stringToInteger } from "../util/stringUtils";
2-
import { Range } from "./Range";
32
import type { TextDocument } from "./TextDocument";
43

54
export class Position {
@@ -158,14 +157,6 @@ export class Position {
158157
);
159158
}
160159

161-
/**
162-
* Create a new empty range from this position.
163-
* @returns A {@link Range}
164-
*/
165-
public toEmptyRange(): Range {
166-
return new Range(this, this);
167-
}
168-
169160
/**
170161
* Return a concise string representation of the position. 0-based.
171162
* @returns concise representation

packages/lib-common/src/types/Range.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,20 @@ export class Range {
2626
`Invalid concise range format: "${concise}". Expected "start-end" format.`,
2727
);
2828
}
29-
const [start, end] = parts.map((s) => Position.fromConcise(s));
29+
const start = Position.fromConcise(parts[0]);
30+
const end = Position.fromConcise(parts[1]);
3031
return new Range(start, end);
3132
}
3233

34+
/**
35+
* Create a new empty range from a position.
36+
* @param position A position.
37+
* @returns A {@link Range}
38+
*/
39+
static fromPosition(position: Position): Range {
40+
return new Range(position, position);
41+
}
42+
3343
/**
3444
* Create a new range from two positions.
3545
* The earlier of `p1` and `p2` will be used as the start position.

packages/lib-common/src/types/SpokenFormType.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { ActionType } from "./command/ActionDescriptor";
12
import type {
2-
ActionType,
33
ModifierType,
44
SimpleScopeTypeType,
55
SurroundingPairName,
6-
} from "@cursorless/lib-common";
6+
} from "./command/PartialTargetDescriptor.types";
77

88
/**
99
* This interface is the source of truth for the types used in our spoken form

packages/lib-common/src/types/TalonSpokenForms.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Notifier } from "@cursorless/lib-common";
1+
import type { Notifier } from "../util/Notifier";
22
import type { SpokenFormMapKeyTypes, SpokenFormType } from "./SpokenFormType";
33

44
/**

packages/lib-common/src/types/TreeSitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Query, Tree } from "web-tree-sitter";
2-
import type { TextDocument } from "@cursorless/lib-common";
2+
import type { TextDocument } from "./TextDocument";
33

44
export interface TreeSitter {
55
/**

packages/lib-engine/src/actions/BreakLine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function getEdits(editor: TextEditor, contentRanges: Range[]): Edit[] {
6565
new Position(line.lineNumber, characterTrailingWhitespace),
6666
position,
6767
)
68-
: position.toEmptyRange();
68+
: Range.fromPosition(position);
6969

7070
edits.push({
7171
range: replacementRange,

packages/lib-engine/src/actions/IndentLine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function getIndentEdits(editor: TextEditor, targets: Target[]) {
9696
return lineNumbers.map((lineNumber) => {
9797
const line = document.lineAt(lineNumber);
9898
return {
99-
range: line.range.start.toEmptyRange(),
99+
range: Range.fromPosition(line.range.start),
100100
text: indent,
101101
};
102102
});

0 commit comments

Comments
 (0)