hinting.ts: Make hintPage follow link if there's only 1 option

This commit is contained in:
glacambre 2018-02-28 22:01:36 +01:00
parent e122caa326
commit 3cd0125783
No known key found for this signature in database
GPG key ID: B9625DB1767553AC

View file

@ -57,6 +57,17 @@ export function hintPage(
buildHints(hintableElements, onSelect)
if (modeState.hints.length) {
let sameLinks = false
for (let hint of modeState.hints) {
sameLinks = hint.target instanceof HTMLAnchorElement
&& hint.target.href === (<HTMLAnchorElement>modeState.hints[0].target).href
if (!sameLinks)
break
}
if (sameLinks) {
modeState.hints[0].select()
reset()
}
logger.debug("hints", modeState.hints)
modeState.focusedHint = modeState.hints[0]
modeState.focusedHint.focused = true
@ -143,7 +154,7 @@ class Hint {
public readonly flag = document.createElement('span')
constructor(
private readonly target: Element,
public readonly target: Element,
public readonly name: string,
public readonly filterData: any,
private readonly onSelect: HintSelectedCallback