Don't send empty commands, use angular model instead of accessing

element value directly. Fixes problem with pressing enter will send
previous value in history.
This commit is contained in:
Tor Hveem 2014-05-07 18:33:47 +02:00
parent 2eddc9ff3d
commit 3f595ea0ac

View file

@ -1264,8 +1264,12 @@ weechat.directive('inputBar', function() {
var input = $scope.getInputNode(); var input = $scope.getInputNode();
var ab = models.getActiveBuffer(); var ab = models.getActiveBuffer();
// It's undefined early in the lifecycle of the program.
// Don't send empty commands
if($scope.command !== undefined && $scope.command !== '') {
// log to buffer history // log to buffer history
ab.addToHistory(input.value); ab.addToHistory($scope.command);
// Split the command into multiple commands based on line breaks // Split the command into multiple commands based on line breaks
_.each($scope.command.split(/\r?\n/), function(line) { _.each($scope.command.split(/\r?\n/), function(line) {
@ -1279,7 +1283,8 @@ weechat.directive('inputBar', function() {
} }
// Empty the input after it's sent // Empty the input after it's sent
input.value = ''; $scope.command = '';
}
}; };
// Handle key presses in the input bar // Handle key presses in the input bar