Skip to content

Commit 4dc6605

Browse files
committed
feat(hints): elide hints for conflicting keymaps
1 parent 63001fb commit 4dc6605

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/glide/browser/base/content/browser-commands.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ class GlideCommandsClass {
166166
return;
167167
}
168168

169-
const labels = Strings.generate_prefix_free_codes(Hinting.ALPHABET, hints.length, Hinting.ALPHABET_COST_MAP);
169+
const hintKeys = glide.keymaps.list("hint").map((k) => k.lhs);
170+
const hintsAlphabet = Hinting.ALPHABET.filter((k) => !hintKeys.includes(k));
171+
const labels = Strings.generate_prefix_free_codes(hintsAlphabet, hints.length, Hinting.ALPHABET_COST_MAP);
170172

171173
for (let i = 0; i < hints.length; i++) {
172174
const hint = hints[i]!;

src/glide/browser/base/content/test/hints/browser_hints.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,27 @@ add_task(async function test_expandable_content_can_be_hinted() {
230230
is(is_open, true, "<details> content should be open after activating the hint");
231231
});
232232
});
233+
234+
add_task(async function test_hint_keymaps_are_ignored() {
235+
await GlideTestUtils.reload_config(function _() {
236+
glide.keymaps.set("hint", "f", "keys <esc>");
237+
glide.keymaps.set("normal", "j", "config_edit");
238+
});
239+
240+
await BrowserTestUtils.withNewTab(FILE, async browser => {
241+
var is_open = await SpecialPowers.spawn(browser, [], () => {
242+
const summary = content.document.getElementById("summary-1");
243+
summary.scrollIntoView();
244+
return summary.parentElement.open;
245+
});
246+
await sleep_frames(10);
247+
is(is_open, false, "<details> content should be hidden by default");
248+
249+
await keys("f");
250+
await wait_for_hints();
251+
252+
const hints = GlideCommands.get_active_hints();
253+
notok(hints.find(hint => hint.label === "f"), "'f' is hidden when remapped in hint mode");
254+
ok(hints.find(hint => hint.label === "j"), "'j' is not mapped in hint mode");
255+
});
256+
});

0 commit comments

Comments
 (0)