Skip to content

Commit

Permalink
update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Dec 13, 2023
1 parent 984555b commit ca48a44
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export function getContainingScopeTarget(
scope = expandFromPosition(
scopeHandler,
editor,
scope.domain.start,
"backward",
ancestorIndex - 1,
scope.domain.end,
"forward",
ancestorIndex,
true,
);
}

Expand Down Expand Up @@ -86,10 +87,12 @@ function expandFromPosition(
position: Position,
direction: Direction,
ancestorIndex: number,
allowAdjacentScopes: boolean = false,
): TargetScope | undefined {
let nextAncestorIndex = 0;
for (const scope of scopeHandler.generateScopes(editor, position, direction, {
containment: "required",
allowAdjacentScopes,
})) {
if (nextAncestorIndex === ancestorIndex) {
return scope;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
languageId: javascript
command:
version: 6
spokenForm: change grand state
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: statement}
ancestorIndex: 1
usePrePhraseSnapshot: true
initialState:
documentContents: |-
class MyClass {
myFunk() {
}
}
selections:
- anchor: {line: 2, character: 8}
active: {line: 2, character: 8}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}

0 comments on commit ca48a44

Please sign in to comment.