Skip to content

Commit

Permalink
keybindings: search improvement
Browse files Browse the repository at this point in the history
closes 11873

Signed-Off-By: FernandoAscencio <fernando.ascencio.cama@ericsson.com>
  • Loading branch information
FernandoAscencio committed Mar 15, 2023
1 parent c7ca0d5 commit c1ca440
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/keymaps/src/browser/keybindings-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class KeybindingWidget extends ReactWidget implements StatefulWidget {

protected formatAndMatchKeybinding(item: KeybindingItem, queryItems: string[]): boolean {
if (item.keybinding) {
let match = false;
const copiedItems = [...queryItems].filter(Boolean); /* Copy query and eliminate empty entries */
const segments = this.keybindingRegistry.resolveKeybinding(item.keybinding).reduce<RenderableStringSegment[]>((collection, code, codeIndex) => {
if (codeIndex !== 0) {
// Two non-breaking spaces.
Expand All @@ -224,14 +224,14 @@ export class KeybindingWidget extends ReactWidget implements StatefulWidget {
if (chunkIndex !== 0) {
collection.push({ value: '+', match: false, key: false });
}
const chunkMatches = queryItems.includes(matchChunks[chunkIndex].toLocaleLowerCase());
match ||= chunkMatches;
const index = copiedItems.indexOf(matchChunks[chunkIndex].toLocaleLowerCase());
const chunkMatches = index > -1 ? !!copiedItems.splice(index, 1) : false;
collection.push({ value: chunk, match: chunkMatches, key: true });
});
return collection;
}, []);
item.labels.keybinding = { value: item.labels.keybinding.value, segments };
return match;
return !copiedItems.length;
}
item.labels.keybinding = { value: '' };
return false;
Expand Down

0 comments on commit c1ca440

Please sign in to comment.