vorpal
Advanced tools
Comparing version 1.10.10 to 1.11.0
@@ -105,23 +105,28 @@ 'use strict'; | ||
} | ||
var furthest = strX; | ||
for (var k = strX.length; k <= matches[0].length; ++k) { | ||
var curr = String(strip(matches[0]).slice(0, k)); | ||
var same = 0; | ||
for (var j = 0; j < matches.length; ++j) { | ||
var sliced = String(strip(matches[j]).slice(0, curr.length)); | ||
if (sliced === curr) { | ||
same++; | ||
} | ||
} | ||
if (same === matches.length) { | ||
furthest = curr; | ||
continue; | ||
} else { | ||
var shortestMatchLength = _.reduce(matches, function (acc, value) { | ||
return value.length < acc ? value.length : acc; | ||
}, 99999); | ||
// starting at position str.length, if all matches share the same char in this | ||
// position, increment position. When we get to a position where not all matches | ||
// match, this is the longest string we can autocomplete | ||
var longestMatchLength = shortestMatchLength; | ||
var firstMatch = matches[0]; | ||
for (var pos = str.length; pos < shortestMatchLength; pos++) { | ||
var allMatchesHaveSameChar = _.every(matches, function (m) { | ||
return m[pos] === firstMatch[pos]; | ||
}); | ||
if (!allMatchesHaveSameChar) { | ||
longestMatchLength = pos; | ||
break; | ||
} | ||
} | ||
if (furthest !== strX) { | ||
return prefix + furthest; | ||
// couldn't resolve any further, return all matches | ||
if (longestMatchLength === str.length) { | ||
return matches; | ||
} | ||
return undefined; | ||
// return the longest matching portion | ||
return matches[0].substr(0, longestMatchLength); | ||
} | ||
@@ -169,2 +174,5 @@ }; | ||
var match = autocomplete.match(trimmed, data.slice(), options); | ||
if (_.isArray(match)) { | ||
return match; | ||
} | ||
var prefix = new Array(len - trimmed.length + 1).join(' '); | ||
@@ -190,2 +198,5 @@ // If we get an autocomplete match on a command, finish it. | ||
function assembleInput(input) { | ||
if (_.isArray(input.context)) { | ||
return input.context; | ||
} | ||
var result = (input.prefix || '') + (input.context || '') + (input.suffix || ''); | ||
@@ -192,0 +203,0 @@ return strip(result); |
@@ -193,3 +193,3 @@ 'use strict'; | ||
var prompt = void 0; | ||
var prompt = undefined; | ||
options = options || {}; | ||
@@ -196,0 +196,0 @@ if (!this.parent) { |
@@ -27,3 +27,3 @@ 'use strict'; | ||
var arr = []; | ||
var match = void 0; | ||
var match = undefined; | ||
do { | ||
@@ -53,5 +53,5 @@ match = reg.exec(str); | ||
var pipes = []; | ||
var match = void 0; | ||
var matchArgs = void 0; | ||
var matchParts = void 0; | ||
var match = undefined; | ||
var matchArgs = undefined; | ||
var matchParts = undefined; | ||
@@ -151,4 +151,4 @@ function parsePipes() { | ||
var match = void 0; | ||
var matchArgs = void 0; | ||
var match = undefined; | ||
var matchArgs = undefined; | ||
for (var i = 0; i < parts.length; ++i) { | ||
@@ -181,4 +181,4 @@ var subcommand = String(parts.slice(0, parts.length - i).join(' ')).trim(); | ||
var wordMatch = false; | ||
for (var _key in allCommands) { | ||
var _cmd2 = allCommands[_key]; | ||
for (var key in allCommands) { | ||
var _cmd2 = allCommands[key]; | ||
var parts2 = String(_cmd2).split(' '); | ||
@@ -185,0 +185,0 @@ var cmdParts = String(match.command).split(' '); |
@@ -552,3 +552,3 @@ 'use strict'; | ||
var prompt = void 0; | ||
var prompt = undefined; | ||
var ssn = _this.getSessionById(options.sessionId); | ||
@@ -555,0 +555,0 @@ |
{ | ||
"name": "vorpal", | ||
"version": "1.10.10", | ||
"version": "1.11.0", | ||
"description": "Node's first framework for building immersive CLI apps.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/vorpal.js", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
3966
116905
16
1
0