Browse Source

[readline, repl] Fix completion grouping, fix parens eval results

handling
Fedor Indutny 13 years ago
parent
commit
71a9aefa0f
  1. 2
      lib/readline.js
  2. 25
      lib/repl.js

2
lib/readline.js

@ -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

@ -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,15 +186,17 @@ function REPLServer(prompt, stream, options) {
// Now as statement without parens.
function tryExpr(ret) {
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 (ret !== undefined) {
self.context._ = ret;
self.outputStream.write(exports.writer(ret) + '\n');
return finish(null);
}
self.bufferedCommand = '';
self.eval(self.bufferedCommand, self.context,
'repl', function(e, ret) {
if (e) {
// instanceof doesn't work across context switches.
@ -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…
Cancel
Save