Merge pull request #291 from torhve/fix-empty

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:
Lorenz Hübschle-Schneider 2014-05-07 18:20:59 +01:00
commit 236b0da97b

View file

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