Allow unsetting extending ansicolors

This commit is contained in:
Simon Lamon
2022-07-19 17:22:54 +00:00
parent 2a0681f0c0
commit 06627cb0bb
2 changed files with 22 additions and 1 deletions
+21 -1
View File
@@ -320,7 +320,7 @@ describe('ColorManager', () => {
}
});
it('should set one extended ansi colors and keep the other default', () => {
it('should set one extended ansi color and keep the other default', () => {
cm.setTheme({
extendedAnsi: ['#ffffff']
});
@@ -328,5 +328,25 @@ describe('ColorManager', () => {
assert.equal(cm.colors.ansi[16].css, '#ffffff');
assert.equal(cm.colors.ansi[17].css, DEFAULT_ANSI_COLORS[17].css);
});
it('should set extended ansi colors to the default after setting to something', () => {
cm.setTheme({
extendedAnsi: ['#ffffff']
});
assert.equal(cm.colors.ansi[16].css, '#ffffff');
cm.setTheme({
extendedAnsi: []
});
assert.equal(cm.colors.ansi[16].css, DEFAULT_ANSI_COLORS[16].css);
cm.setTheme({
extendedAnsi: ['#ffffff']
});
assert.equal(cm.colors.ansi[16].css, '#ffffff');
cm.setTheme({});
assert.equal(cm.colors.ansi[16].css, DEFAULT_ANSI_COLORS[16].css);
});
});
});
+1
View File
@@ -151,6 +151,7 @@ export class ColorManager implements IColorManager {
const opacity = 0.3;
this.colors.selectionTransparent = color.opacity(this.colors.selectionTransparent, opacity);
}
this.colors.ansi = DEFAULT_ANSI_COLORS.slice();
this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);