From 2c3d98abc8976a77df937aa675b62b77eb2bad25 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 25 May 2017 09:36:59 -0700 Subject: [PATCH] Fix bug with parser state when using vtop Fixes #662 --- src/Parser.ts | 3 ++- src/xterm.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Parser.ts b/src/Parser.ts index 5938e2ea..00d574ee 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -181,7 +181,7 @@ export class Parser { * * @param data The data to parse. */ - public parse(data: string) { + public parse(data: string): ParserState { let l = data.length, j, cs, ch, code, low; this._position = 0; @@ -564,6 +564,7 @@ export class Parser { break; } } + return this._state; } /** diff --git a/src/xterm.js b/src/xterm.js index f92a25f7..bf359a92 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1252,7 +1252,13 @@ Terminal.prototype.innerWrite = function() { this.refreshStart = this.y; this.refreshEnd = this.y; - this.parser.parse(data); + // HACK: Set the parser state based on it's state at the time of return. + // This works around the bug #662 which saw the parser state reset in the + // middle of parsing escape sequence in two chunks. For some reason the + // state of the parser resets to 0 after exiting parser.parse. This change + // just sets the state back based on the correct return statement. + var state = this.parser.parse(data); + this.parser.setState(state); this.updateRange(this.y); this.refresh(this.refreshStart, this.refreshEnd);