summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2009-05-20 23:02:42 +1000
committerDoug Kearns <dougkearns@gmail.com>2009-05-22 10:53:12 +1000
commit72aba0f876fe2c758ef2be6c9d1fef1b26af6c83 (patch)
tree45b6d59345fd70f82985198c31a4b3f8740ef75a
parent3df0e174ac6e67bdcbe58486dcbf69d280947664 (diff)
downloadpentadactyl-72aba0f876fe2c758ef2be6c9d1fef1b26af6c83.tar.gz
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.
-rw-r--r--vimperator/content/bookmarks.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js
index fc3b578b..dcf9cbb1 100644
--- a/vimperator/content/bookmarks.js
+++ b/vimperator/content/bookmarks.js
@@ -830,14 +830,20 @@ function History() //{{{
return items;
},
- // TODO: better names and move to buffer.?
+ // TODO: better names
stepTo: function stepTo(steps)
{
- let index = window.getWebNavigation().sessionHistory.index + steps;
- if (index >= 0 && index < window.getWebNavigation().sessionHistory.count)
- window.getWebNavigation().gotoIndex(index);
+ let start = 0;
+ let end = window.getWebNavigation().sessionHistory.count - 1;
+ let current = window.getWebNavigation().sessionHistory.index;
+
+ if (current == start && steps < 0 || current == end && steps > 0)
+ liberator.beep();
else
- liberator.beep(); // XXX: really wanted?
+ {
+ let index = Math.max(start, Math.min(end, current + steps));
+ window.getWebNavigation().gotoIndex(index);
+ }
},
goToStart: function goToStart()
@@ -847,7 +853,7 @@ function History() //{{{
if (index > 0)
window.getWebNavigation().gotoIndex(0);
else
- liberator.beep(); // XXX: really wanted?
+ liberator.beep();
},
@@ -859,7 +865,7 @@ function History() //{{{
if (sh.index < max)
window.getWebNavigation().gotoIndex(max);
else
- liberator.beep(); // XXX: really wanted?
+ liberator.beep();
},