Skip to content

Commit

Permalink
Fixes microsoft#40706: Align Inspect TM Scopes widget implementation …
Browse files Browse the repository at this point in the history
…with the runtime one
  • Loading branch information
alexdima committed Feb 5, 2018
1 parent f6feb04 commit d7cbcea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class InspectTMScopesWidget extends Disposable implements IContentWidget {

let theme = this._themeService.getColorTheme();
result += `<hr class="tm-metadata-separator"/>`;
let matchingRule = findMatchingThemeRule(theme, data.tokens1[token1Index].scopes);
let matchingRule = findMatchingThemeRule(theme, data.tokens1[token1Index].scopes, false);
if (matchingRule) {
result += `<code class="tm-theme-selector">${matchingRule.rawSelector}\n${JSON.stringify(matchingRule.settings, null, '\t')}</code>`;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@

import { IColorTheme, ITokenColorizationSetting } from 'vs/workbench/services/themes/common/workbenchThemeService';

export function findMatchingThemeRule(theme: IColorTheme, scopes: string[]): ThemeRule {
export function findMatchingThemeRule(theme: IColorTheme, scopes: string[], onlyColorRules: boolean = true): ThemeRule {
for (let i = scopes.length - 1; i >= 0; i--) {
let parentScopes = scopes.slice(0, i);
let scope = scopes[i];
let r = findMatchingThemeRule2(theme, scope, parentScopes);
let r = findMatchingThemeRule2(theme, scope, parentScopes, onlyColorRules);
if (r) {
return r;
}
}
return null;
}

function findMatchingThemeRule2(theme: IColorTheme, scope: string, parentScopes: string[]): ThemeRule {
function findMatchingThemeRule2(theme: IColorTheme, scope: string, parentScopes: string[], onlyColorRules: boolean): ThemeRule {
let result: ThemeRule = null;

// Loop backwards, to ensure the last most specific rule wins
for (let i = theme.tokenColors.length - 1; i >= 0; i--) {
let rule = theme.tokenColors[i];
if (!rule.settings.foreground) {
if (onlyColorRules && !rule.settings.foreground) {
continue;
}

Expand Down

0 comments on commit d7cbcea

Please sign in to comment.