mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 22:22:27 +01:00
Don't beep when jumping too far with :back/:forward.
Specifying a count larger than the number of history items shouldn't cause :back and :forward (H and L) to beep. This is also consistent with other commands.
This commit is contained in:
@@ -830,14 +830,20 @@ function History() //{{{
|
|||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: better names and move to buffer.?
|
// TODO: better names
|
||||||
stepTo: function stepTo(steps)
|
stepTo: function stepTo(steps)
|
||||||
{
|
{
|
||||||
let index = window.getWebNavigation().sessionHistory.index + steps;
|
let start = 0;
|
||||||
if (index >= 0 && index < window.getWebNavigation().sessionHistory.count)
|
let end = window.getWebNavigation().sessionHistory.count - 1;
|
||||||
window.getWebNavigation().gotoIndex(index);
|
let current = window.getWebNavigation().sessionHistory.index;
|
||||||
|
|
||||||
|
if (current == start && steps < 0 || current == end && steps > 0)
|
||||||
|
liberator.beep();
|
||||||
else
|
else
|
||||||
liberator.beep(); // XXX: really wanted?
|
{
|
||||||
|
let index = Math.max(start, Math.min(end, current + steps));
|
||||||
|
window.getWebNavigation().gotoIndex(index);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
goToStart: function goToStart()
|
goToStart: function goToStart()
|
||||||
@@ -847,7 +853,7 @@ function History() //{{{
|
|||||||
if (index > 0)
|
if (index > 0)
|
||||||
window.getWebNavigation().gotoIndex(0);
|
window.getWebNavigation().gotoIndex(0);
|
||||||
else
|
else
|
||||||
liberator.beep(); // XXX: really wanted?
|
liberator.beep();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -859,7 +865,7 @@ function History() //{{{
|
|||||||
if (sh.index < max)
|
if (sh.index < max)
|
||||||
window.getWebNavigation().gotoIndex(max);
|
window.getWebNavigation().gotoIndex(max);
|
||||||
else
|
else
|
||||||
liberator.beep(); // XXX: really wanted?
|
liberator.beep();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user