From 72423bf654e27f5902d550edee071e696d296f9c Mon Sep 17 00:00:00 2001 From: gdh1995 Date: Thu, 23 May 2024 02:14:30 +0800 Subject: [PATCH] improve LinkHints.click: add .loop and fix flash rect in focus mode for https://github.com/gdh1995/vimium-c/issues/1129 --- content/link_actions.ts | 5 +++-- content/link_hints.ts | 2 +- typings/messages.d.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/content/link_actions.ts b/content/link_actions.ts index 3f17aee4d..b38c9a71e 100644 --- a/content/link_actions.ts +++ b/content/link_actions.ts @@ -657,14 +657,15 @@ const doPostAction = (): Rect | null => { } else if (forHover_) { (HintMode.HOVER + 1 === HintMode.UNHOVER ? HintMode.HOVER & 1 ? mode1_ & 1 : !(mode1_ & 1) : HintMode.HOVER < HintMode.UNHOVER ? mode1_ < HintMode.HOVER + 1 : mode1_ > HintMode.HOVER - 1) - ? hoverEl() : retPromise = catchAsyncErrorSilently(wrap_enable_bubbles(hintOptions, unhover_async<1>, [clickEl])) + ? hoverEl() : retPromise = catchAsyncErrorSilently(wrap_enable_bubbles(hintOptions, unhover_async<1> + , [realClickEl || clickEl])) } else if (mode1_ < HintMode.FOCUS + 1) { view_(clickEl) setNewScrolling(clickEl) focus_(clickEl) set_cachedScrollable(currentScrolling) showUrlIfNeeded() - removeFlash || showRect && flash_(clickEl) + removeFlash || showRect && flash_(clickEl, tag === "a" || hint.r ? rect as never : null) showRect = 0 } else if (mode1_ < HintMode.max_media + 1) { downloadOrOpenMedia() diff --git a/content/link_hints.ts b/content/link_hints.ts index 46a1cf92f..c29ce1a98 100644 --- a/content/link_hints.ts +++ b/content/link_hints.ts @@ -541,7 +541,7 @@ export const findAnElement_ = (options: OptionsToFindElement, count: number, als compareDocumentPosition(midEl, cur as Element) & kNode.DOCUMENT_POSITION_FOLLOWING // midEl < cur ? low = mid + 1 : high = mid - 1 } - return low < -matchIndex ? end : low + matchIndex + return exOpts.loop ? (low + matchIndex) % end : low < -matchIndex ? end : low + matchIndex } let isSel: boolean | BOOL | undefined let matches: (Hint | Hint0)[] | undefined, oneMatch: Hint | Hint0 | undefined, matchIndex: number diff --git a/typings/messages.d.ts b/typings/messages.d.ts index e786ec8a8..1cc04f42f 100644 --- a/typings/messages.d.ts +++ b/typings/messages.d.ts @@ -69,6 +69,7 @@ interface OptionsToFindElement extends CSSOptions, OtherFilterOptions { search?: "view" | "doc" | "document" offset?: 0 | "cur" | "current" | "end" | "last" index?: "count" | number + loop?: boolean | BOOL } targetOptions?: object }