aboutsummaryrefslogtreecommitdiff
path: root/src/content/usecases/KeymapUseCase.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-12-21 15:08:07 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-12-21 17:12:15 +0900
commitab58c5edb79b4a5aa347e80deaeb612216a9d34e (patch)
treefd28899de0a1a1558961fef105f9a842376b94cf /src/content/usecases/KeymapUseCase.ts
parent493ffc83b01bfbae5f84c66f4db0cc4e1f90a588 (diff)
Add numeric prefix to repeat a command
Diffstat (limited to 'src/content/usecases/KeymapUseCase.ts')
-rw-r--r--src/content/usecases/KeymapUseCase.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts
index f7de334..fab13f5 100644
--- a/src/content/usecases/KeymapUseCase.ts
+++ b/src/content/usecases/KeymapUseCase.ts
@@ -36,13 +36,13 @@ export default class KeymapUseCase {
}
// eslint-disable-next-line max-statements
- nextOps(key: Key): operations.Operation[] {
+ nextOps(key: Key): { count: number, op: operations.Operation } | null {
let sequence = this.repository.enqueueKey(key);
let baseSequence = sequence.trimNumericPrefix();
if (baseSequence.length() === 1 && this.blacklistKey(key)) {
// ignore if the input starts with black list keys
this.repository.clear();
- return [];
+ return null;
}
let keymaps = this.keymapEntityMap();
@@ -53,21 +53,21 @@ export default class KeymapUseCase {
sequence.length() === matched[0][0].length()) {
// keys are matched with an operation
this.repository.clear();
- return [matched[0][1]];
+ return { count: 1, op: matched[0][1] };
} else if (
baseMatched.length === 1 &&
baseSequence.length() === baseMatched[0][0].length()) {
// keys are matched with an operation with a numeric prefix
this.repository.clear();
- return Array(sequence.repeatCount()).fill(baseMatched[0][1]);
+ return { count: sequence.repeatCount(), op: baseMatched[0][1] };
} else if (matched.length >= 1 || baseMatched.length >= 1) {
// keys are matched with an operation's prefix
- return [];
+ return null;
}
// matched with no operations
this.repository.clear();
- return [];
+ return null;
}
private keymapEntityMap(): [KeySequence, operations.Operation][] {