do not use nextTick to wait for flush.

This commit is contained in:
Christopher Jeffrey 2015-07-22 06:03:40 -07:00
parent da59a32ac5
commit 797dcc2369
1 changed files with 10 additions and 5 deletions

View File

@ -1598,7 +1598,9 @@ Program.prototype._write = function(text) {
// Example: `DCS tmux; ESC Pt ST`
// Real: `DCS tmux; ESC Pt ESC \`
Program.prototype._twrite = function(data) {
var self = this;
var self = this
, iterations = 0
, timer;
if (this.tmux) {
// Replace all STs with BELs so they can be nested within the DCS code.
@ -1610,10 +1612,13 @@ Program.prototype._twrite = function(data) {
// If we've never even flushed yet, it means we're still in
// the normal buffer. Wait for alt screen buffer.
if (this.output.bytesWritten === 0) {
nextTick(function() {
self.flush();
self.output.write(data);
});
timer = setInterval(function() {
if (self.output.bytesWritten > 0 || ++iterations === 50) {
clearInterval(timer);
self.flush();
self.output.write(data);
}
}, 100);
return true;
}