Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Dec 8, 2023
1 parent efb53ff commit 55fedd1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Target } from "../../typings/target.types";
import { ModifierStageFactory } from "../ModifierStageFactory";
import type { ModifierStage } from "../PipelineStages.types";
import { constructScopeRangeTarget } from "./constructScopeRangeTarget";
import { getContainingScopeTarget } from "./getContainingScopeTarget";
import { getPreferredScopeTouchingPosition } from "./getPreferredScopeTouchingPosition";
import { runLegacy } from "./relativeScopeLegacy";
import { ScopeHandlerFactory } from "./scopeHandlers/ScopeHandlerFactory";
Expand Down Expand Up @@ -36,13 +37,23 @@ export class RelativeExclusiveScopeStage implements ModifierStage {
const { isReversed, editor, contentRange } = target;
const { length: desiredScopeCount, direction, offset } = this.modifier;

const initialRange =
getPreferredScopeTouchingPosition(
scopeHandler,
editor,
direction === "forward" ? contentRange.start : contentRange.end,
direction,
)?.domain ?? contentRange;
const initialRange = (() => {
if (contentRange.isEmpty) {
return (
getPreferredScopeTouchingPosition(
scopeHandler,
editor,
direction === "forward" ? contentRange.start : contentRange.end,
direction,
)?.domain ?? contentRange
);
}

return (
getContainingScopeTarget(target, scopeHandler)?.[0].contentRange ??
contentRange
);
})();

const initialPosition =
direction === "forward" ? initialRange.end : initialRange.start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ initialState:
active: {line: 0, character: 0}
marks: {}
finalState:
documentContents: aaa(, ccc()) + ddd()
documentContents: "aaa(bbb(), ccc()) + "
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
- anchor: {line: 0, character: 20}
active: {line: 0, character: 20}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ initialState:
active: {line: 0, character: 1}
marks: {}
finalState:
documentContents: aaa(, ccc()) + ddd()
documentContents: "aaa(bbb(), ccc()) + "
selections:
- anchor: {line: 0, character: 4}
active: {line: 0, character: 4}
- anchor: {line: 0, character: 20}
active: {line: 0, character: 20}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
languageId: ruby
command:
version: 5
spokenForm: change second next call
spokenForm: change next call
action: {name: clearAndSetSelection}
targets:
- type: primitive
modifiers:
- type: relativeScope
scopeType: {type: functionCall}
offset: 2
offset: 1
length: 1
direction: forward
usePrePhraseSnapshot: true
Expand Down

0 comments on commit 55fedd1

Please sign in to comment.