Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/api/selections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1401,16 +1401,25 @@ export function shift(
position: vscode.Position,
shift: Shift,
context = Context.current,
skipCharacter: boolean = false,
) {
let anchor = shift === Shift.Jump
? position
: shift === Shift.Select
? selection.active
: selection.anchor;

if (context.selectionBehavior === SelectionBehavior.Character && shift !== Shift.Jump) {
const direction = anchor.isAfter(position) ? Direction.Backward : Direction.Forward;
const direction = anchor.isAfter(position) ? Direction.Backward : Direction.Forward;

if (skipCharacter) {
if (direction === Direction.Forward) {
anchor = Positions.next(anchor) ?? anchor;
} else {
anchor = Positions.previous(anchor) ?? anchor;
}
}

if (context.selectionBehavior === SelectionBehavior.Character && shift !== Shift.Jump) {
anchor = seekFrom(selection, direction, anchor, context);
}

Expand Down
18 changes: 9 additions & 9 deletions src/commands/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/commands/layouts/azerty.fr.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/commands/layouts/qwerty.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/commands/seek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,19 @@ export async function object(
newSelections = Selections.mapByIndex((_i, selection, document) => {
const activePosition = Selections.activePosition(selection, _.document);
let shiftTo = f.start(activePosition, inner, document);
let skipCharacter = false;

if (shiftTo.isEqual(activePosition)) {
const activePositionBefore = Positions.previous(activePosition, document);

skipCharacter = _.selectionBehavior === SelectionBehavior.Character && !inner && shift === Shift.Select;

if (activePositionBefore !== undefined) {
shiftTo = f.start(activePositionBefore, inner, document);
}
}

return Selections.shift(selection, shiftTo, shift, _);
return Selections.shift(selection, shiftTo, shift, _, skipCharacter);
});
} else if (where === "end") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix the issue with "next paragraph", you'd have to find the condition for which to set skipCharacter in the where === "end" branch too. i haven't been able to figure out the right condition.

newSelections = Selections.mapByIndex((_i, selection, document) =>
Expand Down