Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/glide/browser/base/content/browser-hints.mts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ class GlideHintsClass {
* Remove all hints from the DOM tree and switch back to `normal` mode.
*/
remove_hints() {
GlideBrowser._change_mode("normal");
if (GlideBrowser.state.mode === "hint") {
GlideBrowser._change_mode("normal");
}
this.#clear_hints();
}

Expand Down
28 changes: 27 additions & 1 deletion src/glide/browser/base/content/plugins/keymaps.mts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,33 @@ export function init(sandbox: Sandbox) {

// hint mode
glide.keymaps.set("normal", "f", "hint");
glide.keymaps.set("normal", "F", "hint --action=newtab-click");
glide.keymaps.set("normal", "F", () =>
glide.hints.show({
async action({ content }) {
const result = await content.execute((target) => {
const tagName = target.tagName.toLowerCase();
const hasHref = tagName === "a" && (target as HTMLAnchorElement).href !== "";

if (hasHref) {
return { hasHref: true, href: (target as HTMLAnchorElement).href };
} else {
target.focus();
target.$glide_hack_click_from_hint = true;
target.click();
setTimeout(() => {
target.$glide_hack_click_from_hint = false;
}, 10);

return { hasHref: false };
}
});

if (result.hasHref && result.href) {
await gBrowser.addTrustedTab(result.href, { inBackground: true });
}
},
}));

glide.keymaps.set("normal", "<leader>f", "hint --location=browser-ui");
glide.keymaps.set(
"normal",
Expand Down
6 changes: 4 additions & 2 deletions src/glide/browser/base/content/test/hints/browser_hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ add_task(async function test_F_opens_new_tab() {
is(GlideBrowser.state.mode, "normal", "Mode should return to 'normal' after following hint");

if (final_tab_count > initial_tab_count) {
gBrowser.removeTab(gBrowser.selectedTab);
const new_tab = gBrowser.tabs[gBrowser.tabs.length - 1];
gBrowser.removeTab(new_tab);
}
});
});
Expand Down Expand Up @@ -438,7 +439,8 @@ add_task(async function test_numeric_hint_generator() {
is(GlideBrowser.state.mode, "normal", "Mode should return to 'normal' after following hint");

if (final_tab_count > initial_tab_count) {
gBrowser.removeTab(gBrowser.selectedTab);
const new_tab = gBrowser.tabs[gBrowser.tabs.length - 1];
gBrowser.removeTab(new_tab);
}
});
});
Expand Down