Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'case-773254'

  • Loading branch information...
commit 9a6e42c290e922b04e795522a59d23a626474071 2 parents 7dac9ff + 9e5d656
@joewalker joewalker authored
Showing with 33 additions and 8 deletions.
  1. +15 −7 lib/gcli/types/selection.js
  2. +18 −1 lib/gclitest/testIncomplete.js
View
22 lib/gcli/types/selection.js
@@ -53,8 +53,8 @@ exports.shutdown = function() {
* the associated name. However the name maybe available directly from the
* value using a property lookup. Setting 'stringifyProperty' allows
* SelectionType to take this shortcut.
- * - cacheable : If lookup is a function, then we normally assume that
- * the values fetched can change. Setting 'cacheable' enables internal
+ * - cacheable: If lookup is a function, then we normally assume that
+ * the values fetched can change. Setting 'cacheable:true' enables internal
* caching.
*/
function SelectionType(typeSpec) {
@@ -148,6 +148,7 @@ SelectionType.prototype._findPredictions = function(arg) {
var lookup = this.getLookup();
var i, option;
var maxPredictions = Conversion.maxPredictions;
+ var match = arg.text.toLowerCase();
// If the arg has a suffix then we're kind of 'done'. Only an exact match
// will do.
@@ -162,10 +163,18 @@ SelectionType.prototype._findPredictions = function(arg) {
return predictions;
}
+ // Cache lower case versions of all the option names
+ for (i = 0; i < lookup.length; i++) {
+ option = lookup[i];
+ if (option._gcliLowerName == null) {
+ option._gcliLowerName = option.name.toLowerCase();
+ }
+ }
+
// Start with prefix matching
for (i = 0; i < lookup.length && predictions.length < maxPredictions; i++) {
option = lookup[i];
- if (option.name.indexOf(arg.text) === 0) {
+ if (option._gcliLowerName.indexOf(match) === 0) {
this._addToPredictions(predictions, option, arg);
}
}
@@ -174,7 +183,7 @@ SelectionType.prototype._findPredictions = function(arg) {
if (predictions.length < (maxPredictions / 2)) {
for (i = 0; i < lookup.length && predictions.length < maxPredictions; i++) {
option = lookup[i];
- if (option.name.indexOf(arg.text) !== -1) {
+ if (option._gcliLowerName.indexOf(match) !== -1) {
if (predictions.indexOf(option) === -1) {
this._addToPredictions(predictions, option, arg);
}
@@ -189,7 +198,7 @@ SelectionType.prototype._findPredictions = function(arg) {
return opt.name;
});
speller.train(names);
- var corrected = speller.correct(arg.text);
+ var corrected = speller.correct(match);
if (corrected) {
lookup.forEach(function(opt) {
if (opt.name === corrected) {
@@ -226,9 +235,8 @@ SelectionType.prototype.parse = function(arg) {
this.noMatch();
}
- var value = predictions[0].value;
-
if (predictions[0].name === arg.text) {
+ var value = predictions[0].value;
return new Conversion(value, arg, Status.VALID, '', predictions);
}
View
19 lib/gclitest/testIncomplete.js
@@ -185,8 +185,25 @@ exports.testCompleted = function(options) {
secure: { value: false, status: 'VALID' }
}
});
+};
- // Expand out to christmas tree command line
+exports.testCase = function(options) {
+ helpers.setInput('tsg AA');
+ helpers.check({
+ input: 'tsg AA',
+ markup: 'VVVVII',
+ directTabText: '',
+ arrowTabText: 'aaa',
+ status: 'ERROR',
+ emptyParameters: [ ],
+ args: {
+ solo: { value: undefined, text: 'AA', status: 'INCOMPLETE' },
+ txt1: { value: undefined, status: 'VALID' },
+ bool: { value: undefined, status: 'VALID' },
+ txt2: { value: undefined, status: 'VALID' },
+ num: { value: undefined, status: 'VALID' }
+ }
+ });
};
exports.testIncomplete = function(options) {
Please sign in to comment.
Something went wrong with that request. Please try again.