From 9ba2471ce0bfbd24dab2f40c60389262e6825d52 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Wed, 29 May 2019 16:32:59 +0100 Subject: [PATCH] WIP: show possible matches in mode indicator --- src/content/controller_content.ts | 14 +++++++++++--- src/lib/keyseq.ts | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/content/controller_content.ts b/src/content/controller_content.ts index fc305733..5cefde47 100644 --- a/src/content/controller_content.ts +++ b/src/content/controller_content.ts @@ -11,6 +11,7 @@ const logger = new Logger("controller") function PrintableKey(k) { let result = k.key + console.log(k) if ( result === "Control" || result === "Meta" || @@ -156,10 +157,17 @@ function* ParserController() { exstr = response.exstr break } else { - keyEvents = response.keys + keyEvents = response.potMatches + console.log([...keyEvents.keys()]) // show current keyEvents as a suffix of the contentState - contentState.suffix = keyEvents - .map(x => PrintableKey(x)) + contentState.suffix = [...keyEvents.keys()] + .map(y => { + console.log(y) + ; (y as any).map(x => { + console.log(x) + PrintableKey(x.key) + }).join(" ") + }) .join("") logger.debug("suffix: ", contentState.suffix) } diff --git a/src/lib/keyseq.ts b/src/lib/keyseq.ts index 7b0c9430..04dcb796 100644 --- a/src/lib/keyseq.ts +++ b/src/lib/keyseq.ts @@ -112,6 +112,7 @@ export interface ParserResponse { exstr?: any isMatch: boolean numericPrefix?: number + potMatches?: KeyMap } export function parse(keyseq: KeyEventLike[], map: KeyMap): ParserResponse { @@ -156,7 +157,7 @@ export function parse(keyseq: KeyEventLike[], map: KeyMap): ParserResponse { // command, numericPrefix is a numeric prefix of that. We want to // preserve that whole thing, so concat them back together before // returning. - return { keys: numericPrefix.concat(keyseq), isMatch: keyseq.length > 0 } + return { keys: numericPrefix.concat(keyseq), isMatch: keyseq.length > 0, potMatches: possibleMappings } } /** True if seq1 is a prefix or equal to seq2 */