readEditor error handling.

This commit is contained in:
Christopher Jeffrey 2013-09-14 00:01:24 -05:00
parent ac54a9d944
commit c5d2c45f19
1 changed files with 18 additions and 1 deletions

View File

@ -1552,6 +1552,10 @@ Screen.prototype.readEditor = function(options, callback) {
options = null;
}
if (!callback) {
callback = function() {};
}
options = options || {};
var self = this
@ -1580,6 +1584,7 @@ Screen.prototype.readEditor = function(options, callback) {
if (err) return callback(err);
return fs.readFile(file, 'utf8', function(err, data) {
return fs.unlink(file, function() {
if (!success) return callback(new Error('Unsuccessful.'));
if (err) return callback(err);
return callback(null, data);
});
@ -4716,8 +4721,20 @@ Textarea.prototype.readEditor = function(callback) {
};
}
if (!callback) {
callback = function() {};
}
return this.screen.readEditor({ value: this.value }, function(err, value) {
if (err) return callback && callback(err);
if (err) {
if (err.message === 'Unsuccessful.') {
self.screen.render();
return self.readInput(callback);
}
self.screen.render();
self.readInput(callback);
return callback(err);
}
self.setValue(value);
self.screen.render();
return self.readInput(callback);