Fix problems with inputbar history and nick complete

This commit is contained in:
Tor Hveem 2014-05-08 00:04:12 +02:00
parent 236b0da97b
commit 06f3e50684

View file

@ -1248,9 +1248,6 @@ weechat.directive('inputBar', function() {
// input DOM node // input DOM node
var inputNode = $scope.getInputNode(); var inputNode = $scope.getInputNode();
// get current input
var inputText = inputNode.value;
// get current caret position // get current caret position
var caretPos = inputNode.selectionStart; var caretPos = inputNode.selectionStart;
@ -1258,14 +1255,14 @@ weechat.directive('inputBar', function() {
var activeBuffer = models.getActiveBuffer(); var activeBuffer = models.getActiveBuffer();
// complete nick // complete nick
var nickComp = IrcUtils.completeNick(inputText, caretPos, var nickComp = IrcUtils.completeNick($scope.command, caretPos,
$scope.iterCandidate, activeBuffer.getNicklistByTime(), ':'); $scope.iterCandidate, activeBuffer.getNicklistByTime(), ':');
// remember iteration candidate // remember iteration candidate
$scope.iterCandidate = nickComp.iterCandidate; $scope.iterCandidate = nickComp.iterCandidate;
// update current input // update current input
inputNode.value = nickComp.text; $scope.command = nickComp.text;
// update current caret position // update current caret position
inputNode.focus(); inputNode.focus();
@ -1358,7 +1355,7 @@ weechat.directive('inputBar', function() {
if ($event.altKey && (code === 76 || code === 108)) { if ($event.altKey && (code === 76 || code === 108)) {
$event.preventDefault(); $event.preventDefault();
inputNode.focus(); inputNode.focus();
inputNode.setSelectionRange(inputNode.value.length, inputNode.value.length); inputNode.setSelectionRange($scope.command.length, $scope.command.length);
return true; return true;
} }
@ -1392,18 +1389,18 @@ weechat.directive('inputBar', function() {
// Arrow up -> go up in history // Arrow up -> go up in history
if (code === 38) { if (code === 38) {
inputNode.value = models.getActiveBuffer().getHistoryUp(inputNode.value); $scope.command = models.getActiveBuffer().getHistoryUp($scope.command);
// Set cursor to last position. Need 0ms timeout because browser sets cursor // Set cursor to last position. Need 0ms timeout because browser sets cursor
// position to the beginning after this key handler returns. // position to the beginning after this key handler returns.
setTimeout(function() { setTimeout(function() {
inputNode.setSelectionRange(inputNode.value.length, inputNode.value.length); inputNode.setSelectionRange($scope.command.length, $scope.command.length);
}, 0); }, 0);
return true; return true;
} }
// Arrow down -> go down in history // Arrow down -> go down in history
if (code === 40) { if (code === 40) {
inputNode.value = models.getActiveBuffer().getHistoryDown(inputNode.value); $scope.command = models.getActiveBuffer().getHistoryDown($scope.command);
// We don't need to set the cursor to the rightmost position here, the browser does that for us // We don't need to set the cursor to the rightmost position here, the browser does that for us
return true; return true;
} }