Move function declaration to top-level
Gets rid of a strict mode error and a few levels of indentation.
This commit is contained in:
parent
e5bb8391a8
commit
0b0b72c2fa
@ -346,8 +346,35 @@ Interface.prototype._tabComplete = function() {
|
||||
return a.length > b.length ? a : b;
|
||||
}).length + 2; // 2 space padding
|
||||
var maxColumns = Math.floor(self.columns / width) || 1;
|
||||
var group = [], c;
|
||||
for (var i = 0, compLen = completions.length; i < compLen; i++) {
|
||||
c = completions[i];
|
||||
if (c === '') {
|
||||
handleGroup.call(self, group);
|
||||
group = [];
|
||||
} else {
|
||||
group.push(c);
|
||||
}
|
||||
}
|
||||
handleGroup.call(self, group);
|
||||
|
||||
// If there is a common prefix to all matches, then apply that
|
||||
// portion.
|
||||
var f = completions.filter(function(e) { if (e) return e; });
|
||||
var prefix = commonPrefix(f);
|
||||
if (prefix.length > completeOn.length) {
|
||||
self._insertString(prefix.slice(completeOn.length));
|
||||
}
|
||||
|
||||
}
|
||||
self._refreshLine();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// this = Interface instance
|
||||
function handleGroup(group) {
|
||||
var self = this;
|
||||
if (group.length == 0) {
|
||||
return;
|
||||
}
|
||||
@ -372,33 +399,6 @@ Interface.prototype._tabComplete = function() {
|
||||
self.output.write('\r\n');
|
||||
}
|
||||
|
||||
var group = [], c;
|
||||
for (var i = 0, compLen = completions.length; i < compLen; i++) {
|
||||
c = completions[i];
|
||||
if (c === '') {
|
||||
handleGroup(group);
|
||||
group = [];
|
||||
} else {
|
||||
group.push(c);
|
||||
}
|
||||
}
|
||||
handleGroup(group);
|
||||
|
||||
// If there is a common prefix to all matches, then apply that
|
||||
// portion.
|
||||
var f = completions.filter(function(e) { if (e) return e; });
|
||||
var prefix = commonPrefix(f);
|
||||
if (prefix.length > completeOn.length) {
|
||||
self._insertString(prefix.slice(completeOn.length));
|
||||
}
|
||||
|
||||
}
|
||||
self._refreshLine();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function commonPrefix(strings) {
|
||||
if (!strings || strings.length == 0) {
|
||||
return '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user