Skip to content

Commit 29cd1ec

Browse files
committed
feat: add option to disable number prefix parsing
1 parent 45ecbe9 commit 29cd1ec

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@
237237
"description": "Clear selections when running command setInsertMode",
238238
"deprecationMessage": "Deprecated: use modalEditor.clearSelections by yourself instead",
239239
"default": true
240+
},
241+
"modalEditor.misc.parseNumberPrefix": {
242+
"type": "boolean",
243+
"description": "Parse leading number as prefix instead of normal keys",
244+
"default": true
240245
}
241246
}
242247
}

src/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ export class AppState {
156156
// common keymap
157157
this.config.keybindings[""],
158158
// whether it's command mode
159-
mode === COMMAND
159+
mode === COMMAND,
160+
this.config.misc.parseNumberPrefix
160161
);
161162
}
162163

src/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export type Misc = {
6767
/// Default to use when extension starts
6868
defaultMode: string,
6969
/// Clear selections when running command setInsertMode (deprecated)
70-
clearSelectionsOnInsertMode: boolean
70+
clearSelectionsOnInsertMode: boolean,
71+
/// Parse leading number as prefix instead of normal keys
72+
parseNumberPrefix: boolean,
7173
};
7274

7375
/**
@@ -106,7 +108,8 @@ const defaultMisc: Misc = {
106108
presetDirectory: "~/.config/vscode-modal-editor",
107109
autoloadPreset: "",
108110
defaultMode: NORMAL,
109-
clearSelectionsOnInsertMode: true
111+
clearSelectionsOnInsertMode: true,
112+
parseNumberPrefix: true,
110113
};
111114

112115
export function getStyle(mode: string, styles: Styles) {

src/keybindings.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ export class KeyEventHandler {
4747
keys!: string;
4848
/// Count prefix
4949
count!: string;
50-
/// Whether it is parsing the prefix count
50+
/// Whether it is parsing the number prefix
5151
parsingCount!: boolean;
5252

5353
constructor(
5454
public keyStatusBar: vscode.StatusBarItem,
5555
public keymap: Keymap | undefined,
5656
public commonKeymap: Keymap | undefined,
57-
public commandMode: boolean
57+
public commandMode: boolean,
58+
/// Whether to parse number prefix
59+
public parseNumberPrefix: boolean,
5860
) {
5961
this.reset();
6062
}
@@ -177,7 +179,7 @@ export class KeyEventHandler {
177179
this.currentKeymap = this.keymap;
178180
this.currentCommonKeymap = this.commonKeymap;
179181
this.count = "";
180-
this.parsingCount = true;
182+
this.parsingCount = this.parseNumberPrefix;
181183
this.setKeys("");
182184
}
183185

0 commit comments

Comments
 (0)