Skip to content

Commit 8e015eb

Browse files
authored
Merge pull request #4950 from Tyriar/tyriar/blending
Fix background selection blending for true color
2 parents 99df13b + 3c88c76 commit 8e015eb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/browser/renderer/shared/CellColorResolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class CellColorResolver {
9292
$bg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba;
9393
break;
9494
case Attributes.CM_RGB:
95-
$bg = (this.result.fg & Attributes.RGB_MASK) << 8 | 0xFF;
95+
$bg = ((this.result.fg & Attributes.RGB_MASK) << 8) | 0xFF;
9696
break;
9797
case Attributes.CM_DEFAULT:
9898
default:
@@ -105,7 +105,7 @@ export class CellColorResolver {
105105
$bg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba;
106106
break;
107107
case Attributes.CM_RGB:
108-
$bg = this.result.bg & Attributes.RGB_MASK << 8 | 0xFF;
108+
$bg = ((this.result.bg & Attributes.RGB_MASK) << 8) | 0xFF;
109109
break;
110110
// No need to consider default bg color here as it's not possible
111111
}
@@ -143,7 +143,7 @@ export class CellColorResolver {
143143
$fg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba;
144144
break;
145145
case Attributes.CM_RGB:
146-
$fg = this.result.bg & Attributes.RGB_MASK << 8 | 0xFF;
146+
$fg = ((this.result.bg & Attributes.RGB_MASK) << 8) | 0xFF;
147147
break;
148148
// No need to consider default bg color here as it's not possible
149149
}
@@ -154,7 +154,7 @@ export class CellColorResolver {
154154
$fg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba;
155155
break;
156156
case Attributes.CM_RGB:
157-
$fg = (this.result.fg & Attributes.RGB_MASK) << 8 | 0xFF;
157+
$fg = ((this.result.fg & Attributes.RGB_MASK) << 8) | 0xFF;
158158
break;
159159
case Attributes.CM_DEFAULT:
160160
default:

test/playwright/SharedRendererTests.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { IImage32, decodePng } from '@lunapaint/png-codec';
77
import { LocatorScreenshotOptions, test } from '@playwright/test';
88
import { ITheme } from '@xterm/xterm';
9-
import { ITestContext, MaybeAsync, openTerminal, pollFor, pollForApproximate } from './TestUtils';
9+
import { ITestContext, MaybeAsync, openTerminal, pollFor, pollForApproximate, timeout } from './TestUtils';
1010

1111
export interface ISharedRendererTestContext {
1212
value: ITestContext;
@@ -989,13 +989,15 @@ export function injectSharedRendererTests(ctx: ISharedRendererTestContext): void
989989
};
990990
await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`);
991991
await ctx.value.proxy.focus();
992-
await ctx.value.proxy.writeln('\x1b[41m red bg');
993-
await ctx.value.proxy.writeln('\x1b[7m inverse');
994-
await ctx.value.proxy.writeln('\x1b[31;7m red fg inverse');
992+
await ctx.value.proxy.writeln('\x1b[41m red bg\x1b[0m');
993+
await ctx.value.proxy.writeln('\x1b[7m inverse\x1b[0m');
994+
await ctx.value.proxy.writeln('\x1b[31;7m red fg inverse\x1b[0m');
995+
await ctx.value.proxy.writeln('\x1b[48:2:0:204:0:0m red truecolor bg\x1b[0m');
995996
await ctx.value.proxy.selectAll();
996-
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [230,128,128,255]);
997-
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 2), [255,255,255,255]);
998-
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 3), [230,128,128,255]);
997+
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [230, 128, 128, 255]);
998+
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 2), [255, 255, 255, 255]);
999+
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 3), [230, 128, 128, 255]);
1000+
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 4), [230, 128, 128, 255]);
9991001
});
10001002
test('powerline decorative symbols', async () => {
10011003
const theme: ITheme = {

0 commit comments

Comments
 (0)