Skip to content

Commit b5511d7

Browse files
jspammaxauthority
authored andcommitted
Fix #718: Do not call _processHints after following a unique hint. (#720)
* Refactoring: Avoid a _chars2num call in _checkUnique. By definition of the chars2num function, `this._chars2num(options.hintchars[0])` is always 0. * Fix #718: Do not call `_processHints` after following a unique hint. When following a unique hint, the `_validHints` array is cleared, thus the second call of `_processHints` triggers a `beep()` after following a hint.
1 parent f4ee1c5 commit b5511d7

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

common/content/hints.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,24 +647,33 @@ const Hints = Module("hints", {
647647
return true;
648648
},
649649

650+
/**
651+
* Checks whether the current _hintNumber uniquely identifies a hint and if yes, follows it.
652+
* If not, but options.hinttimeout is set, follows the hint after a timeout.
653+
*
654+
* @return whether a unique hint was found and followed without a timeout.
655+
*/
650656
_checkUnique: function () {
651657
if (
652658
this._hintNumber === null ||
653-
this._hintNumber === this._chars2num(options.hintchars[0]) ||
659+
this._hintNumber === 0 ||
654660
this._hintNumber > this._validHints.length
655661
) {
656-
return;
662+
return false;
657663
}
658664

659665
// if we write a numeric part like 3, but we have 45 hints, only follow
660666
// the hint after a timeout, as the user might have wanted to follow link 34
661-
if (this._hintNumber > 0 && this._hintNumber * options.hintchars.length <= this._validHints.length) {
667+
if (this._hintNumber * options.hintchars.length <= this._validHints.length) {
662668
let timeout = options.hinttimeout;
663669
if (timeout > 0)
664670
this._activeTimeout = this.setTimeout(function () { this._processHints(true); }, timeout);
671+
return false;
665672
}
666-
else // we have a unique hint
673+
else { // we have a unique hint
667674
this._processHints(true);
675+
return true;
676+
}
668677
},
669678

670679
/**
@@ -1075,7 +1084,9 @@ const Hints = Module("hints", {
10751084

10761085
this._showActiveHint(this._hintNumber, oldHintNumber || 1);
10771086

1078-
this._checkUnique();
1087+
if (this._checkUnique()) {
1088+
return;
1089+
}
10791090
}
10801091

10811092
this._updateStatusline();

0 commit comments

Comments
 (0)