Skip to content

Commit 9c7ddfe

Browse files
authored
cull dead code (#1889)
Suggested by some linter in GitHub Actions amidst a bunch of other scrollback. ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent afa3802 commit 9c7ddfe

File tree

1 file changed

+2
-95
lines changed

1 file changed

+2
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import {
2-
Direction,
3-
Position,
4-
TextDocument,
5-
TextEditor,
6-
showError,
7-
} from "@cursorless/common";
1+
import { Direction, Position, TextEditor, showError } from "@cursorless/common";
82
import { uniqWith } from "lodash";
93
import { TreeSitterQuery } from "../../../../languages/TreeSitterQuery";
104
import { QueryMatch } from "../../../../languages/TreeSitterQuery/QueryCapture";
115
import BaseScopeHandler from "../BaseScopeHandler";
126
import { compareTargetScopes } from "../compareTargetScopes";
137
import { TargetScope } from "../scope.types";
14-
import {
15-
ContainmentPolicy,
16-
ScopeIteratorRequirements,
17-
} from "../scopeHandler.types";
8+
import { ScopeIteratorRequirements } from "../scopeHandler.types";
189
import { mergeAdjacentBy } from "./mergeAdjacentBy";
1910
import { ide } from "../../../../singletons/ide.singleton";
2011

@@ -105,87 +96,3 @@ export abstract class BaseTreeSitterScopeHandler extends BaseScopeHandler {
10596
export interface ExtendedTargetScope extends TargetScope {
10697
allowMultiple: boolean;
10798
}
108-
109-
/**
110-
* Constructs a range to pass to {@link Query.matches} to find scopes. Note
111-
* that {@link Query.matches} will only return scopes that have non-empty
112-
* intersection with this range. Also note that the base
113-
* {@link BaseScopeHandler.generateScopes} will filter out any extra scopes
114-
* that we yield, so we don't need to be totally precise.
115-
*
116-
* @returns Range to pass to {@link Query.matches}
117-
*/
118-
function getQuerySearchRange(
119-
document: TextDocument,
120-
position: Position,
121-
direction: Direction,
122-
{
123-
containment,
124-
distalPosition,
125-
allowAdjacentScopes,
126-
}: ScopeIteratorRequirements,
127-
) {
128-
const { start, end } = getQuerySearchRangeCore(
129-
document.offsetAt(position),
130-
document.offsetAt(distalPosition),
131-
direction,
132-
containment,
133-
allowAdjacentScopes,
134-
);
135-
136-
return {
137-
start: document.positionAt(start),
138-
end: document.positionAt(end),
139-
};
140-
}
141-
142-
/** Helper function for {@link getQuerySearchRange} */
143-
function getQuerySearchRangeCore(
144-
offset: number,
145-
distalOffset: number,
146-
direction: Direction,
147-
containment: ContainmentPolicy | null,
148-
allowAdjacentScopes: boolean,
149-
) {
150-
/**
151-
* If we allow adjacent scopes, we need to shift some of our offsets by one
152-
* character
153-
*/
154-
const adjacentShift = allowAdjacentScopes ? 1 : 0;
155-
156-
if (containment === "required") {
157-
// If containment is required, we smear the position left and right by one
158-
// character so that we have a non-empty intersection with any scope that
159-
// touches position. Note that we can skip shifting the initial position
160-
// if we disallow adjacent scopes.
161-
return direction === "forward"
162-
? {
163-
start: offset - adjacentShift,
164-
end: offset + 1,
165-
}
166-
: {
167-
start: offset - 1,
168-
end: offset + adjacentShift,
169-
};
170-
}
171-
172-
// If containment is disallowed, we can shift the position forward by a
173-
// character to avoid matching scopes that touch position. Otherwise, we
174-
// shift the position backward by a character to ensure we get scopes that
175-
// touch position, if we allow adjacent scopes.
176-
const proximalShift = containment === "disallowed" ? 1 : -adjacentShift;
177-
178-
// FIXME: Don't go all the way to end of document when there is no
179-
// distalPosition? Seems wasteful to query all the way to end of document for
180-
// something like "next funk" Might be better to start smaller and
181-
// exponentially grow
182-
return direction === "forward"
183-
? {
184-
start: offset + proximalShift,
185-
end: distalOffset + adjacentShift,
186-
}
187-
: {
188-
start: distalOffset - adjacentShift,
189-
end: offset - proximalShift,
190-
};
191-
}

0 commit comments

Comments
 (0)