Skip to content

Commit 36a8d60

Browse files
Pass requireStrongContainment from head/tail modifier to interior scope handler (#3072)
The test failed before this fix `(a)| b` `"change tail"` and you expect `| b` but because the domain of the surrounding pair interior is the entire surrounding pair you instead removed `)`. This fix requires strong containments on surrounding pair interiors.
1 parent 2da41e4 commit 36a8d60

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
languageId: plaintext
2+
command:
3+
version: 7
4+
spokenForm: change tail
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- {type: extendThroughEndOf}
11+
usePrePhraseSnapshot: false
12+
initialState:
13+
documentContents: (a) b
14+
selections:
15+
- anchor: {line: 0, character: 3}
16+
active: {line: 0, character: 3}
17+
marks: {}
18+
finalState:
19+
documentContents: (a)
20+
selections:
21+
- anchor: {line: 0, character: 3}
22+
active: {line: 0, character: 3}

packages/common/src/types/command/PartialTargetDescriptor.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ export interface InteriorScopeType {
240240

241241
// The user has specified a scope type. eg "inside element".
242242
explicitScopeType?: boolean;
243+
244+
// Gets passed to surrounding pair scope handler
245+
requireStrongContainment?: boolean;
243246
}
244247

245248
export type SurroundingPairDirection = "left" | "right";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class BoundedLineStage implements ModifierStage {
101101
try {
102102
return this.getContaining(target, options, {
103103
type: "interior",
104+
requireStrongContainment: true,
104105
});
105106
} catch (error) {
106107
if (error instanceof NoContainingScopeError) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class InteriorScopeHandler extends BaseScopeHandler {
7474
{
7575
type: "surroundingPair",
7676
delimiter: "any",
77+
requireStrongContainment: this.scopeType.requireStrongContainment,
7778
},
7879
this.languageId,
7980
);

0 commit comments

Comments
 (0)