Skip to content

Commit

Permalink
Fix one-off with spanning new line by escape
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvisser committed May 25, 2014
1 parent 275abb1 commit 2b9d1a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports.getAutocompleteArguments = function(currentCommand, currentLine,
// the end of the command string). Therefore, we'll assign it an index at the end of the input
// string
if (!_.isNumber(lastArg.i)) {
lastArg.i = fullCommandStr.length - 1;
lastArg.i = fullCommandStr.length;
}

if (fullCommandParsed.open === CommandParser.OPEN_ESCAPE) {
Expand Down
11 changes: 11 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ describe('Auto-complete', function() {
});
});

it('does not abort when empty argument spans to second line with escape sequence', function(callback) {
CommandAutocomplete.getAutocompleteArguments('my args \\\n', '', function(abort, args) {
assert.ok(!abort);
assert.strictEqual(args.length, 3);
assert.strictEqual(args[0], 'my');
assert.strictEqual(args[1], 'args');
assert.strictEqual(args[2], '');
return callback();
});
});

it('provides unquoted arguments', function(callback) {
CommandAutocomplete.getAutocompleteArguments(null, 'my commands are', function(abort, args) {
assert.ok(!abort);
Expand Down

0 comments on commit 2b9d1a8

Please sign in to comment.