Make InputHandler parseAnsiColorChange private

This commit is contained in:
Slawek Zachcial
2020-11-29 16:30:05 +01:00
parent 4c6dc45d20
commit 52b64beefc
2 changed files with 9 additions and 14 deletions
+7 -10
View File
@@ -1694,16 +1694,13 @@ describe('InputHandler', () => {
});
describe('OSC', () => {
it('should ignore incorrect Ansi color change data', () => {
assert.deepEqual(inputHandler.parseAnsiColorChange('17;rgb:1a/2b/3c'), {
colorIndex: 17,
red: 0x1a,
green: 0x2b,
blue: 0x3c
});
assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c'));
assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:#aabbcc'));
assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc'));
assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc'));
// this is testing a private method
const parseAnsiColorChange = inputHandler["_parseAnsiColorChange"];
assert.isNull(parseAnsiColorChange('17;rgb:a/b/c'));
assert.isNull(parseAnsiColorChange('17;rgb:#aabbcc'));
assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc'));
assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc'));
});
it('should fire event on Ansi color change', (done) => {
inputHandler.onAnsiColorChange(e => {
+2 -4
View File
@@ -2714,9 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler {
this._iconName = data;
}
// This is really an internal method and not part of IInputHandler implementation.
// Making it public so that I can test it.
public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null {
private _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null {
// example data: 5;rgb:aa/bb/cc
const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/;
const match = data.match(regex);
@@ -2739,7 +2737,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits.
*/
public setAnsiColor(data: string): void {
const event = this.parseAnsiColorChange(data);
const event = this._parseAnsiColorChange(data);
if (event) {
this._onAnsiColorChange.fire(event);
}