sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 585 forks source link

(JavaScript) unicode highlighting missing with many nested functions #1130

Closed pdknsk closed 7 years ago

pdknsk commented 7 years ago
x.y(function() {
x.y(function() {
x.y(function() {
x.y(function() {
x.y(function() {
x.y(function() {
var z = '\u1000';
});
});
});
});
});  
});

1

One less and it works.

2

pdknsk commented 7 years ago

Alternatively, each callback function can be replaced with not less than 3 regular functions, in any order.

x.y(function() {
x.y(function() {
x.y(function() {
x.y(function() {
x.y(function() {
function() {
function() {
function() {
var z = '\u1000';
};
};
};
});
});
});
});
});

1

keith-hall commented 7 years ago

Which ST build are you seeing this on? It seems fine for me in 3142 with the default JavaScript syntax.

pdknsk commented 7 years ago

Your comment made me try Monokai – works. Only occurs with Blackboard, and perhaps others.

keith-hall commented 7 years ago

I enabled legacy color schemes and tried, but it still looks okay to me: image

It seems to me like a similar issue to https://github.com/sublimehq/Packages/issues/403, but that was solved in build 3115. Can you confirm what ST build you are using please?

pdknsk commented 7 years ago

I'm on 3126 and tried both the default and the most-recent from-here package.

pdknsk commented 7 years ago

I only noticed after commenting that your image exhibits the bug!

keith-hall commented 7 years ago

Oh I see it now too :) sorry, not used to that color scheme so wasn't sure what to look for.

It looks like the scoring given for the scope selector string and the scope selector constant used in Blackboard.tmTheme are the same:

>>> sublime.score_selector('source.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.block.js meta.block.js meta.block.js string.quoted.single.js constant.character.escape.js', 'constant')
1152921504606846976
>>> sublime.score_selector('source.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.function-call.method.js meta.group.js meta.block.js meta.block.js meta.block.js meta.block.js string.quoted.single.js constant.character.escape.js', 'string')
1152921504606846976

Normally constant would indeed have a higher match score, but I guess that is the largest scope stack / match score that ST can deal with:

>>> sublime.score_selector('source.js string.quoted.single.js constant.character.escape.js', 'string')
64
>>> sublime.score_selector('source.js string.quoted.single.js constant.character.escape.js', 'constant')
512

As string is defined on line 93, and constant on line 41, string takes precedence when the scores are equal - you can "fix" this by moving the constant rules lower down in the tmTheme file so they will take precedence over string.

As this is a legacy color scheme, I'm not sure if such a change will be made to the version that comes with ST.

pdknsk commented 7 years ago

Thanks! Works for me. It seems inevitable to eventually move off of Blackboard. I noticed some nice features in Monokai missing in Blackboard, like cursive formatting.