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;
|
return a.length > b.length ? a : b;
|
||||||
}).length + 2; // 2 space padding
|
}).length + 2; // 2 space padding
|
||||||
var maxColumns = Math.floor(self.columns / width) || 1;
|
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);
|
||||||
|
|
||||||
function 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// this = Interface instance
|
||||||
|
function handleGroup(group) {
|
||||||
|
var self = this;
|
||||||
if (group.length == 0) {
|
if (group.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -370,34 +397,7 @@ Interface.prototype._tabComplete = function() {
|
|||||||
self.output.write('\r\n');
|
self.output.write('\r\n');
|
||||||
}
|
}
|
||||||
self.output.write('\r\n');
|
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) {
|
function commonPrefix(strings) {
|
||||||
if (!strings || strings.length == 0) {
|
if (!strings || strings.length == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user