Skip to content

Commit e3f0772

Browse files
Cleanup
1 parent 2eaba5f commit e3f0772

File tree

10 files changed

+16
-36
lines changed

10 files changed

+16
-36
lines changed

packages/cursorless-engine/src/languages/TreeSitterQuery/TreeSitterQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class TreeSitterQuery {
110110
match: treeSitter.QueryMatch,
111111
): MutableQueryMatch {
112112
return {
113-
patternIdx: match.pattern,
113+
patternIdx: match.patternIndex,
114114
captures: match.captures.map(({ name, node }) => ({
115115
name,
116116
node,

packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ export class EveryScopeStage implements ModifierStage {
111111
const iterationScopeTarget = getContainingScopeTarget(
112112
target,
113113
iterationScopeHandler,
114-
0, // ancestorIndex
115-
true, // skipEmptyScopes
116114
);
117115

118116
if (iterationScopeTarget == null) {

packages/cursorless-engine/src/processTargets/modifiers/getContainingScopeTarget.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export function getContainingScopeTarget(
1717
target: Target,
1818
scopeHandler: ScopeHandler,
1919
ancestorIndex: number = 0,
20-
skipEmptyScopes?: boolean,
2120
): Target[] | undefined {
2221
const {
2322
isReversed,
@@ -27,13 +26,7 @@ export function getContainingScopeTarget(
2726

2827
if (end.isEqual(start)) {
2928
// Input target is empty; return the preferred scope touching target
30-
let scope = getPreferredScopeTouchingPosition(
31-
scopeHandler,
32-
editor,
33-
start,
34-
undefined,
35-
skipEmptyScopes,
36-
);
29+
let scope = getPreferredScopeTouchingPosition(scopeHandler, editor, start);
3730

3831
if (scope == null) {
3932
return undefined;

packages/cursorless-engine/src/processTargets/modifiers/getPreferredScopeTouchingPosition.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export function getPreferredScopeTouchingPosition(
2929
editor: TextEditor,
3030
position: Position,
3131
forceDirection?: Direction,
32-
skipEmptyScopes?: boolean,
3332
): TargetScope | undefined {
3433
/**
3534
* We're looking for the minimal scopes that contain position. We'll get:
@@ -44,7 +43,6 @@ export function getPreferredScopeTouchingPosition(
4443
containment: "required",
4544
allowAdjacentScopes: true,
4645
skipAncestorScopes: true,
47-
skipEmptyScopes: skipEmptyScopes ?? false,
4846
}),
4947
);
5048

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const DEFAULT_REQUIREMENTS: Omit<ScopeIteratorRequirements, "distalPosition"> =
1919
allowAdjacentScopes: false,
2020
skipAncestorScopes: false,
2121
includeDescendantScopes: false,
22-
skipEmptyScopes: false,
2322
};
2423

2524
/**

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/SurroundingPairScopeHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@ import type {
44
SurroundingPairScopeType,
55
TextEditor,
66
} from "@cursorless/common";
7-
import { showError, type ScopeType } from "@cursorless/common";
7+
import { showError } from "@cursorless/common";
88
import type { LanguageDefinitions } from "../../../../languages/LanguageDefinitions";
99
import { ide } from "../../../../singletons/ide.singleton";
1010
import { BaseScopeHandler } from "../BaseScopeHandler";
1111
import { compareTargetScopes } from "../compareTargetScopes";
1212
import type { TargetScope } from "../scope.types";
13-
import type { ScopeIteratorRequirements } from "../scopeHandler.types";
13+
import type {
14+
ConditionalScopeType,
15+
ScopeIteratorRequirements,
16+
} from "../scopeHandler.types";
1417
import { createTargetScope } from "./createTargetScope";
1518
import { getDelimiterOccurrences } from "./getDelimiterOccurrences";
1619
import { getIndividualDelimiters } from "./getIndividualDelimiters";
1720
import { getSurroundingPairOccurrences } from "./getSurroundingPairOccurrences";
1821
import type { SurroundingPairOccurrence } from "./types";
1922

2023
export class SurroundingPairScopeHandler extends BaseScopeHandler {
21-
public readonly iterationScopeType: ScopeType = { type: "line" };
24+
public readonly iterationScopeType: ConditionalScopeType = {
25+
type: "conditional",
26+
scopeType: { type: "line" },
27+
predicate: (scope) => !scope.domain.isEmpty,
28+
};
2229
protected isHierarchical = true;
2330

2431
constructor(

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/TreeSitterScopeHandler/TreeSitterIterationScopeHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export class TreeSitterIterationScopeHandler extends BaseTreeSitterScopeHandler
4747

4848
const { range: contentRange, allowMultiple } = capture;
4949

50+
if (contentRange.isEmpty) {
51+
return undefined;
52+
}
53+
5054
const domain =
5155
getRelatedRange(match, scopeTypeType, "iteration.domain", false) ??
5256
contentRange;

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/scopeHandler.types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,6 @@ export interface ScopeIteratorRequirements {
178178
*/
179179
skipAncestorScopes: boolean;
180180

181-
/**
182-
* Indicates whether the ScopeHandler should skip yielding a scope if it's
183-
* range is empty.
184-
* - `true` means that empty scopes will not be yielded.
185-
* - `false` means that empty scopes will be yielded
186-
*
187-
* @default false
188-
*/
189-
skipEmptyScopes: boolean;
190-
191181
/**
192182
* Indicates whether the ScopeHandler should yield a scope if it is a
193183
* descendant of any scope that has been previously yielded.

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/shouldYieldScope.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function checkRequirements(
5757
distalPosition,
5858
allowAdjacentScopes,
5959
skipAncestorScopes,
60-
skipEmptyScopes,
6160
} = requirements;
6261
const { domain } = scope;
6362

@@ -88,13 +87,6 @@ function checkRequirements(
8887
return false;
8988
}
9089

91-
if (
92-
skipEmptyScopes &&
93-
!scope.getTargets(false).some((t) => !t.contentRange.isEmpty)
94-
) {
95-
return false;
96-
}
97-
9890
return partiallyContains(
9991
new Range(position, distalPosition),
10092
domain,

packages/cursorless-engine/src/scopeProviders/getIterationScopeRanges.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export function getIterationScopeRanges(
4141
{
4242
includeDescendantScopes: true,
4343
distalPosition: iterationRange.end,
44-
skipEmptyScopes: true,
4544
},
4645
),
4746
(scope) => {

0 commit comments

Comments
 (0)