Fix one off bug causing ansi badness

This commit is contained in:
Bryan Ashby 2017-09-03 13:28:45 -06:00
parent 88777c6723
commit 1c8e6d702c
1 changed files with 15 additions and 13 deletions

View File

@ -95,6 +95,7 @@ function ANSIEscapeParser(options) {
start = pos; start = pos;
self.column = 1; self.column = 1;
self.positionUpdated(); self.positionUpdated();
break; break;
@ -103,20 +104,19 @@ function ANSIEscapeParser(options) {
start = pos; start = pos;
self.row += 1; self.row += 1;
self.positionUpdated(); self.positionUpdated();
break; break;
default : default :
if(self.column > self.termWidth) { if(self.column === self.termWidth) {
self.emit('literal', text.slice(start, pos)); self.emit('literal', text.slice(start, pos + 1));
start = pos; start = pos + 1;
self.column = 1; self.column = 1;
self.row += 1; self.row += 1;
self.positionUpdated();
//self.emit('literal', text.slice(pos - 1, pos)); self.positionUpdated();
//start = pos;
} else { } else {
self.column += 1; self.column += 1;
} }
@ -126,17 +126,19 @@ function ANSIEscapeParser(options) {
++pos; ++pos;
} }
//
// Finalize this chunk
//
if(self.column > self.termWidth) { if(self.column > self.termWidth) {
self.emit('literal', text.slice(start, pos - 1));
start = pos - 1;
self.column = 1; self.column = 1;
self.row += 1; self.row += 1;
self.positionUpdated();
self.emit('literal', text.slice(start, pos)); self.positionUpdated();
} else { }
self.emit('literal', text.slice(start));
const rem = text.slice(start);
if(rem) {
self.emit('literal', rem);
} }
} }