[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) {
|
||||
return a.length > b.length ? a : b;
|
||||
}).length + 2; // 2 space padding
|
||||
var maxColumns = Math.floor(this.columns / width) || 1;
|
||||
var maxColumns = Math.floor(self.columns / width) || 1;
|
||||
|
||||
function handleGroup(group) {
|
||||
if (group.length == 0) {
|
||||
|
25
lib/repl.js
25
lib/repl.js
@ -64,10 +64,10 @@ module.paths = require('module')._nodeModulePaths(module.filename);
|
||||
exports.writer = util.inspect;
|
||||
|
||||
|
||||
function REPLServer(prompt, stream, options) {
|
||||
function REPLServer(prompt, stream) {
|
||||
var self = this;
|
||||
|
||||
self.eval = options && options.eval || function(code, context, file, cb) {
|
||||
self.eval = function(code, context, file, cb) {
|
||||
try {
|
||||
var err, result = vm.runInContext(code, context, file);
|
||||
} catch (e) {
|
||||
@ -186,16 +186,18 @@ function REPLServer(prompt, stream, options) {
|
||||
|
||||
// Now as statement without parens.
|
||||
function tryExpr(ret) {
|
||||
|
||||
self.bufferedCommand = '';
|
||||
|
||||
if (ret !== undefined) {
|
||||
self.context._ = ret;
|
||||
self.outputStream.write(exports.writer(ret) + '\n');
|
||||
return finish(null);
|
||||
}
|
||||
|
||||
self.eval(self.bufferedCommand, self.context,
|
||||
'repl', function(e, ret) {
|
||||
|
||||
if (ret !== undefined) {
|
||||
self.context._ = ret;
|
||||
self.outputStream.write(exports.writer(ret) + '\n');
|
||||
}
|
||||
|
||||
self.bufferedCommand = '';
|
||||
|
||||
if (e) {
|
||||
// instanceof doesn't work across context switches.
|
||||
if (!(e && e.constructor && e.constructor.name === 'SyntaxError')) {
|
||||
@ -467,13 +469,16 @@ REPLServer.prototype.complete = function(line, callback) {
|
||||
filter = expr + '.' + filter;
|
||||
}
|
||||
}
|
||||
|
||||
finish();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If reach this point - work like sync
|
||||
finish(null, ret);
|
||||
finish(null);
|
||||
function finish(err, ret) {
|
||||
if (err) throw err;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user