Skip to content

Commit

Permalink
Merge ed54676 into 8d16bb6
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar authored Oct 9, 2018
2 parents 8d16bb6 + ed54676 commit 7eeab73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/InputHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,11 @@ describe('InputHandler', () => {
}
expect(s).equals('World ');
});
describe('print', () => {
it('should not cause an infinite loop (regression test)', () => {
const term = new Terminal();
const inputHandler = new InputHandler(term);
inputHandler.print(String.fromCharCode(0x200B), 0, 1);
});
});
});
6 changes: 4 additions & 2 deletions src/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ export class InputHandler extends Disposable implements IInputHandler {
// fullwidth char - also set next cell to placeholder stub and advance cursor
// for graphemes bigger than fullwidth we can simply loop to zero
// we already made sure above, that buffer.x + chWidth will not overflow right
while (--chWidth) {
bufferRow.set(buffer.x++, [curAttr, '', 0, undefined]);
if (chWidth > 0) {
while (--chWidth) {
bufferRow.set(buffer.x++, [curAttr, '', 0, undefined]);
}
}
}
this._terminal.updateRange(buffer.y);
Expand Down

0 comments on commit 7eeab73

Please sign in to comment.