Move cursor to end when navigating history

Fixes #244
This commit is contained in:
Lorenz Hübschle-Schneider 2014-04-05 22:18:48 +02:00
parent 61ded6f2c4
commit 10bbb63929

View file

@ -1291,12 +1291,18 @@ weechat.directive('inputBar', function() {
// Arrow up -> go up in history
if (code === 38) {
inputNode.value = models.getActiveBuffer().getHistoryUp(inputNode.value);
// Set cursor to last position. Need 0ms timeout because browser sets cursor
// position to the beginning after this key handler returns.
setTimeout(function() {
inputNode.setSelectionRange(inputNode.value.length, inputNode.value.length);
}, 0);
return true;
}
// Arrow down -> go down in history
if (code === 40) {
inputNode.value = models.getActiveBuffer().getHistoryDown(inputNode.value);
// We don't need to set the cursor to the rightmost position here, the browser does that for us
return true;
}
};