This commit is contained in:
Alex Dima
2017-03-29 16:06:30 +02:00
parent 265c96b275
commit 5e234bf101
3 changed files with 37 additions and 11 deletions
+3 -3
View File
@@ -420,9 +420,9 @@
"resolved": "https://registry.npmjs.org/vscode-ripgrep/-/vscode-ripgrep-0.0.11.tgz"
},
"vscode-textmate": {
"version": "3.1.2",
"from": "vscode-textmate@3.1.2",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-3.1.2.tgz"
"version": "3.1.3",
"from": "vscode-textmate@3.1.3",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-3.1.3.tgz"
},
"windows-foreground-love": {
"version": "0.1.0",
+1 -1
View File
@@ -37,7 +37,7 @@
"v8-profiler": "jrieken/v8-profiler#vscode",
"vscode-debugprotocol": "1.18.0",
"vscode-ripgrep": "0.0.11",
"vscode-textmate": "^3.1.2",
"vscode-textmate": "^3.1.3",
"winreg": "1.2.0",
"xterm": "Tyriar/xterm.js#vscode-release/1.11",
"yauzl": "2.3.1"
@@ -71,14 +71,40 @@ export class ThemeRule {
return ThemeRule._matches(this.scope, this.parentScopes, scope, parentScopes);
}
private static _cmp(a: ThemeRule, b: ThemeRule): number {
if (a === null && b === null) {
return 0;
}
if (a === null) {
// b > a
return -1;
}
if (b === null) {
// a > b
return 1;
}
if (a.scope.length !== b.scope.length) {
// longer scope length > shorter scope length
return a.scope.length - b.scope.length;
}
const aParentScopesLen = a.parentScopes.length;
const bParentScopesLen = b.parentScopes.length;
if (aParentScopesLen !== bParentScopesLen) {
// more parents > less parents
return aParentScopesLen - bParentScopesLen;
}
for (let i = 0; i < aParentScopesLen; i++) {
var aLen = a.parentScopes[i].length;
var bLen = b.parentScopes[i].length;
if (aLen !== bLen) {
return aLen - bLen;
}
}
return 0;
}
public isMoreSpecific(other: ThemeRule): boolean {
if (other === null) {
return true;
}
if (other.scope.length === this.scope.length) {
return this.parentScopes.length > other.parentScopes.length;
}
return (this.scope.length > other.scope.length);
return (ThemeRule._cmp(this, other) > 0);
}
private static _matchesOne(selectorScope: string, scope: string): boolean {