Skip to content

Commit

Permalink
commands: remap {a-x,s-a-x}to {x,a-x} (#281)
Browse files Browse the repository at this point in the history
Also fix issues with `.selections.trimLines` and
`.selections.expandToLines` and upgrade `typescript`.
  • Loading branch information
71 committed Nov 4, 2022
1 parent 5779d9c commit a3772ef
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 159 deletions.
2 changes: 1 addition & 1 deletion package.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
"source-map-support": "^0.5.21",
"ts-loader": "^9.3.1",
"ts-node": "^10.8.1",
"typescript": "^4.7.4",
"typescript": "^4.8.4",
"unexpected": "^13.0.0",
"vsce": "^2.7.0",
"webpack": "^5.72.1",
Expand Down
23 changes: 8 additions & 15 deletions package.json

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

2 changes: 1 addition & 1 deletion src/api/data/commands.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function build(builder: Builder) {
}
}

if (command.commands !== existingCommandDoc.get("command", false) as string) {
if (command.commands !== existingCommandDoc.get("commands", false) as string) {
if (command.commands === undefined) {
existingCommandDoc.delete("commands");
} else {
Expand Down
16 changes: 4 additions & 12 deletions src/api/data/commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1655,24 +1655,16 @@ select.line.below:
title:
en: Select line below

keys:
qwerty: |-
`x` (kakoune: normal)
doc:
en: |+
en: |
Select line below.
select.line.below.extend:
title:
en: Extend to line below

keys:
qwerty: |-
`s-x` (kakoune: normal)
doc:
en: |+
en: |
Extend to line below.
select.lineEnd:
Expand Down Expand Up @@ -2014,7 +2006,7 @@ selections.expandToLines:

keys:
qwerty: |-
`a-x` (kakoune: normal)
`x` (kakoune: normal)
doc:
en: |+
Expand Down Expand Up @@ -2460,7 +2452,7 @@ selections.trimLines:

keys:
qwerty: |-
`s-a-x` (kakoune: normal)
`a-x` (kakoune: normal)
doc:
en: |+
Expand Down
20 changes: 20 additions & 0 deletions src/api/selections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,26 @@ export function isNonDirectional(selection: vscode.Selection, context = Context.
&& isSingleCharacter(selection, context.document);
}

/**
* Returns whether the current selection is _strictly reversed_, i.e. it is both
* **directional** (non-empty, and more than one characters in `character`
* selection mode) and reversed.
*
* {@link vscode.Selection.isReversed} returns `true` even for empty selections,
* which is not suitable in many cases.
*/
export function isStrictlyReversed(selection: vscode.Selection, context = Context.current) {
if (selection.isEmpty || !selection.isReversed) {
// Empty or forward: not reversed.
return false;
}

// In `caret` selection mode, we can stop checking here. In `character`
// selection mode, 1-character selections are considered "empty", and
// therefore not reversed.
return !isNonDirectional(selection, context);
}

/**
* The position from which a seek operation should start. This is equivalent
* to `selection.active` except when the selection is non-directional, in
Expand Down
72 changes: 33 additions & 39 deletions src/commands/README.md

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

Loading

0 comments on commit a3772ef

Please sign in to comment.