-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement IGrammar tokenizeLine2 like vscode-textmate #38
Comments
tokenizeLine2. See eclipse-tm4e#38
@sebthom I see that you are very activated on TM4E. Thanks for your contribution! If you have (a lot) time, I think it should be really nice to work on this issue. I had implemented tokenizeLine2, but I didn't consume it. It should b ereally nice to consume it. Why using tokenizeLine2? I suggest that you read https://code.visualstudio.com/blogs/2017/02/08/syntax-highlighting-optimizations |
@angelozerr I had a look at I only ever get two int values back per line. E.g. I have the following test: @Test
void testTokenizeLine2() throws Exception {
final var path = "JavaScript.tmLanguage";
try (var in = Data.class.getResourceAsStream(path)) {
final var grammar = new Registry().loadGrammarFromPathSync(path, in);
final var lineTokens = grammar.tokenizeLine("function add(a,b) { return a+b; }");
for (int i = 0; i < lineTokens.getTokens().length; i++) {
final var token = lineTokens.getTokens()[i];
final String s = "Token from " + token.getStartIndex() + " to " + token.getEndIndex() + " with scopes "
+ token.getScopes();
System.out.println(s);
}
System.out.println("----------");
final var lineTokens2 = grammar.tokenizeLine2("function add(a,b) { return a+b; }");
for (int i = 0; i < lineTokens2.getTokens().length; i++) {
int token = lineTokens2.getTokens()[i];
System.out.println(token);
}
} It outputs:
I would have expected to at least get more than two ints back with any thoughts? |
To be honnest with you when I implemented that I have just copy paste code from vscode textmate and translate it from typescript to java without understand. I did the same things for tests if I remember. I cannot help you more but I think it can be good to study it because vscode uses this strategy and not the the old strategy than tm4e is using. |
Is this possible that after this change embeded grammars will be better detected? Or this might be java oniguruma implementation problem? |
@zulus to be honnest with you, I don't know. I did that to try to have the same behavior than vscode-textmate. |
Thanks, I'll try ;) Currently vue grammars behave differently in compare to vscode (and other text-mate based editors like nova in osx). For example I haven't javascript coloring inside |
See microsoft/vscode#16206 (comment) and https://github.com/Microsoft/vscode-textmate/blob/master/src/tests/themedTokenizer.ts#L25
The tokenizeLine2 seems to provide:
The text was updated successfully, but these errors were encountered: