[readline, repl] Fix completion grouping, fix parens eval results
handling
This commit is contained in:
parent
42b8b77d9f
commit
71a9aefa0f
@ -271,7 +271,7 @@ Interface.prototype._tabComplete = function() {
|
|||||||
var width = completions.reduce(function(a, b) {
|
var width = completions.reduce(function(a, b) {
|
||||||
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(this.columns / width) || 1;
|
var maxColumns = Math.floor(self.columns / width) || 1;
|
||||||
|
|
||||||
function handleGroup(group) {
|
function handleGroup(group) {
|
||||||
if (group.length == 0) {
|
if (group.length == 0) {
|
||||||
|
17
lib/repl.js
17
lib/repl.js
@ -64,10 +64,10 @@ module.paths = require('module')._nodeModulePaths(module.filename);
|
|||||||
exports.writer = util.inspect;
|
exports.writer = util.inspect;
|
||||||
|
|
||||||
|
|
||||||
function REPLServer(prompt, stream, options) {
|
function REPLServer(prompt, stream) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.eval = options && options.eval || function(code, context, file, cb) {
|
self.eval = function(code, context, file, cb) {
|
||||||
try {
|
try {
|
||||||
var err, result = vm.runInContext(code, context, file);
|
var err, result = vm.runInContext(code, context, file);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -186,15 +186,17 @@ function REPLServer(prompt, stream, options) {
|
|||||||
|
|
||||||
// Now as statement without parens.
|
// Now as statement without parens.
|
||||||
function tryExpr(ret) {
|
function tryExpr(ret) {
|
||||||
self.eval(self.bufferedCommand, self.context,
|
|
||||||
'repl', function(e, ret) {
|
self.bufferedCommand = '';
|
||||||
|
|
||||||
if (ret !== undefined) {
|
if (ret !== undefined) {
|
||||||
self.context._ = ret;
|
self.context._ = ret;
|
||||||
self.outputStream.write(exports.writer(ret) + '\n');
|
self.outputStream.write(exports.writer(ret) + '\n');
|
||||||
|
return finish(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bufferedCommand = '';
|
self.eval(self.bufferedCommand, self.context,
|
||||||
|
'repl', function(e, ret) {
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
// instanceof doesn't work across context switches.
|
// instanceof doesn't work across context switches.
|
||||||
@ -467,13 +469,16 @@ REPLServer.prototype.complete = function(line, callback) {
|
|||||||
filter = expr + '.' + filter;
|
filter = expr + '.' + filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If reach this point - work like sync
|
// If reach this point - work like sync
|
||||||
finish(null, ret);
|
finish(null);
|
||||||
function finish(err, ret) {
|
function finish(err, ret) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user