Skip to content

Commit f8a0382

Browse files
committed
[semantic highlighting] functions in josef.rouge-theme get wrong color. Fixes microsoft#92536
1 parent b723595 commit f8a0382

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/vs/workbench/services/themes/common/colorThemeData.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,11 @@ export class ColorThemeData implements IColorTheme {
289289
const settings = tokenColors[i].settings;
290290
if (score >= foregroundScore && settings.foreground) {
291291
foreground = settings.foreground;
292+
foregroundScore = score;
292293
}
293294
if (score >= fontStyleScore && types.isString(settings.fontStyle)) {
294295
fontStyle = settings.fontStyle;
296+
fontStyleScore = score;
295297
}
296298
}
297299
}
@@ -642,7 +644,7 @@ function nameMatcher(identifers: string[], scope: ProbeScope): number {
642644
let lastScopeIndex = scope.length - 1;
643645
let lastIdentifierIndex = findInIdents(scope[lastScopeIndex--], identifers.length);
644646
if (lastIdentifierIndex >= 0) {
645-
const score = (lastIdentifierIndex + 1) * 0x10000 + scope.length;
647+
const score = (lastIdentifierIndex + 1) * 0x10000 + identifers[lastIdentifierIndex].length;
646648
while (lastScopeIndex >= 0) {
647649
lastIdentifierIndex = findInIdents(scope[lastScopeIndex--], lastIdentifierIndex);
648650
if (lastIdentifierIndex === -1) {

src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,41 @@ suite('Themes - TokenStyleResolving', () => {
289289

290290
});
291291

292+
293+
test('resolveScopes - match most specific', async () => {
294+
const themeData = ColorThemeData.createLoadedEmptyTheme('test', 'test');
295+
296+
const customTokenColors: ITokenColorCustomizations = {
297+
textMateRules: [
298+
{
299+
scope: 'entity.name.type',
300+
settings: {
301+
fontStyle: 'underline',
302+
foreground: '#A6E22E'
303+
}
304+
},
305+
{
306+
scope: 'entity.name.type.class',
307+
settings: {
308+
foreground: '#FF00FF'
309+
}
310+
},
311+
{
312+
scope: 'entity.name',
313+
settings: {
314+
foreground: '#FFFFFF'
315+
}
316+
},
317+
]
318+
};
319+
320+
themeData.setCustomTokenColors(customTokenColors);
321+
322+
const tokenStyle = themeData.resolveScopes([['entity.name.type.class']]);
323+
assertTokenStyle(tokenStyle, ts('#FF00FF', { underline: true }), 'entity.name.type.class');
324+
325+
});
326+
292327
test('rule matching', async () => {
293328
const themeData = ColorThemeData.createLoadedEmptyTheme('test', 'test');
294329
themeData.setCustomColors({ 'editor.foreground': '#000000' });

0 commit comments

Comments
 (0)