-
Notifications
You must be signed in to change notification settings - Fork 18
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
Naomi breaks syntax highlighting for LaTeX and MarkdownEditing #117
Comments
I believe I found the error to be related to styled components or template strings. Do you have a sample of a working Latex code that have embedded javascript? |
Sorry I have never used embedded JavaScript in my LaTeX files. Do you believe that this happens only when we embed JS into the other syntaxes? |
This bug was puzzling, the only time I was able to reproduce it was in a dev build I used on a friend's PC; I use the 3143 and the recursion bug does not happen there, so it's a regression in dev build. |
These error messages normally tell you some scopes not being popped off correctly, causing the scope stack to be flooded. To prevent overflow and app crash no more than 25000 levels are allowed. I realized these issues several times during developing my CNC syntaxes. An example of code which causes issues might be helpful for detailed debugging. It's not quite obvious how Disabling MardownEditing and opening a .md file using Naomi's syntax seemed not to highlight anything at all. The .md was a readme created by create-react-app. It's quite long. Without detailed info about the combination of languages triggering the issue I guess it will be hard to find the culprit. I guess if |
@deathaxe Most of the contexts pop after matching, the biggest issue is that it does not happen in the build 3143, the LaTeX works, embedded javascript uses the Naomi's version as expected. This is what puzzled me for a while, I don't use the dev builds, when I got to a computer with it, all I need to do for the error to appear is select the LaTeX syntax. |
@deathaxe Another option that could be added to the core, is a option to print the trace of the supposed recursion. |
The initial post doesn't state anything about LaTeX with embedded JavaScript but Markdown and a LaTeX file. I actually opened a couple of LaTeX files and Markdowns with Naomi enabled on ST3160 without any issue. As I am not a LaTeX expert I can't judge which constructs may trigger the issue. An example to reproduce might therefore help finding the culprit. EDIT: Need to correct myself. Just set up a vanilla 3160 and hit the issue. |
The culprit seems to be the naomi.fjsx15.sublime-syntax. What I didOpen LaTeX file from http://www.electronics.oulu.fi/latex/examples/example_1/example1.html Step 1 - renaming one naomi syntax after another Step 2 - commenting out some lines in syntaxes/naomi.fjsx15.sublime-syntax
Step 3 - following the comment breadcrumps via syntaxes/fjsx15/comments.sublime-syntax to syntaxes/flow1/comments.sublime-syntax Step 4 - commenting out all the includes within syntaxes/flow1/comments.sublime-syntax
Step 5 No more errors. AlternativeMoving the includes out of the
ConclusionThere is at least one pop too much or too less somewhere. Despite the fact your file structure is "unique" compared to all the other syntax projects, I am not sure whether the pop statements always work as you seem to expect them to do.
Hope it doesn't sound too negative! As the risk of popping one stack-level too much or too less is very high, I honestly doubt the core to be blamed. As more and more syntaxes embed others the risk of stack overflow increases if at least one of them doesn't handle stack push/pop correclty. Popping off a level too much or less can cause more troubles then. I had to struggle with such issues, too, when embedding some of my CNC languages into others. |
@deathaxe Thank you for taking your time on this one. I know, I went a step too far with the modularity and the combination of multiple files might be giving headaches with some new feature, but the interesting bit is that the bug does not happen in the build 3143(the one I use), I had to ask help because the bug never seam to happen on my machine. By default all files pop from the main as it allows me to treat it like a normal context so for example, in the case of functions I could do:
And have the body and parameters in different files. This prevents the syntax from having thousands of lines, specially because I often times have lists of functions (javascript core), lists of properties (css); sublime never seam to complain about it, the When a main or context does not pop I add a suffix ".no-pop". But like I said, the recursion does not happen in the build 3143, so something changed since them in the dev build (which I am guessing is the embed feature). I also suggested the stack trace because recursion bugs are always hard to track, but in this case it does look like an error in the core, otherwise it would happen in the build 3143 too. |
@deathaxe Yesterday I went to a friend's house to test the patches you showed as he uses the dev build(I can't test it on my machines right now, too many projects openned). None of the patches worked, what is even stranger is that the bug seams random, often times I would comment parts of the syntax and it would be ok, but then if I tried just adding a dummy context, for example:
The bug would come back. It looks like a hard limit on the number of contexts or files involved when the embed feature is used, but I can't say for sure because the place that caused the bug would change from time to time (which I am guessing is a result of listing the files as the OS (Windows at least) does not garantee the files to be listed alphabetically). |
I agree with a function to help tracing such issues would help very much.
I had same experiences yesterday. I first commented out the But this is what I experienced in the past, too, when I added some unbalanced push/pops into my files. It seemed to work for smaller files, but when they got too big, I hit the sanity limit. What I can see here feels exactly like that. 3143 vs. 3160Loading my example1.tex to 3143 takes quite long to load. It feels like 3160 just gives up more quickly just like the sanity limit was recently added. ST3143 even got unresponsive once, when loading the file for the very first time. Using the LaTeX package from 3143 in 3160 fails, too. So this issue is related to a change in core (added sanity limit?). Not sure whether it is related, but I can see a couple of issues in 3143's console. Maybe they give some hints about possible reasons. Unreachable sections in a syntax file feel not too ideal. Note: This is the only language triggering such issues and is the one, which triggers the sanity limit. :-/
About embedThe LaTeX in 3143 embeds syntaxes like this
The
The major difference between both is the I don't find related issues in https://github.com/SublimeTextIssues/Core/issues at the moment, but I think I can remember an issue with If I were you, I'd try to avoid including a whole syntax (including the
but rather include the stuff in dedicated sections like
This is what I did successfully in the past, when I intended to share some rules. This is what PackageDev does successfully, too. |
I am not tracking all of the details of this issue, but I saw I was mentioned. One of the biggest difference between 3143 and 3160 is that we now have a global regex cache, so if the regex patterns for multiple contexts are the same, we reference a single set instead of allocating new memory for each copy. This would likely explain why 3160 would hit the recursion detection faster, since it likely would not need to re-allocate duplicate regex objects. Generally the memory usage is lower (up to 30% lower total app memory usage), and loading syntaxes is faster. I would check and make sure the user doesn't have any overrides in places. This could easily cause funky include loops. |
I should note that the sanity limit of 25,000 (realized) contexts in a single syntax has been around for a long time. Due to the new At it's worst case, I believe the default syntaxes had a syntax (ASP) that expanded to around 8,000 contexts. Other syntaxes were much more sane, with contexts in the hundreds. I think the second highest was possibly LaTeX with around 3,500. This is largely due to embedding many other complete syntaxes. |
@deathaxe Those unreachable contexts seam really strange specially the name "anon_main_0", I never name it like that, from what I tested, it was related to this with_prototype, but I don't why is giving off these warnings, the code seams fine. @wbond Yes, the limit existed before, but this time it is intermittent, sometimes commenting out parts of the syntax makes the error go away, then adding a dummy context makes the error appear again. |
Perhaps you've written a syntax with 25,000 contexts? |
@wbond Also, the time I tested, the sublime's installation was clean, no overrides, but it only happens in build > 3143, I wasn't able to pin point which dev build started the issue. |
The unreachable context warnings were fixed in build 3154. It happens when you push into an anonymous context combined with a |
There's 467 syntax files in the repo, I rarelly go beyond 10 contexts per file and even in that case, it would be bellow the 25k limit; but like you said, the limit existed in previous builds, so it should happen in the build 3143 too. |
A lot of the default syntaxes have had changes during the current dev cycle, especially the JS syntax. I am sure there are more contexts now than in 3143.
Every |
Isn't the include just a reference to the external file? I thought it was working this way because the cache files are on average ~1kb, the fjsx15 entry point is just 76kb on windows. Is there a function in the API that I can call to count the contexts? |
Every syntax is 100% standalone. It will reference the definition from another syntax, but at run time all of the contexts are compiled into the current syntax. This is for performance reasons, and because a syntax can only be used by a single view at a time. It also allows things like There are two cache files for syntaxes, the cache of the parsed, memory-layout of the contexts, and a cache of all of the compiled regex patterns. The context cache file is usually pretty small, but the regex cache ( |
Currently there is no API or functionality to count the number of contexts in a syntax |
I am also having same issue, installed Naomi, will break |
@pzgz The latest updates in the dev build + naomi hit the limit of 25k contexts, the stable 3143 build does not have this problem. Currently I am writting a build system to concatenate the syntax files into 1 which will drastically reduce the amount of contexts. |
@borela Thanks a lot, I will keep watch on this, though I am also considering that error messages from ST3 is kind of confusing... |
@pzgz It puzzled me too for a while specially because I use the stable build from ST3 where It does not happen. When I wrote Naomi, I broke the syntax into multiple files and every time I needed to reuse some contexts, I just referenced that file. The issue is that every After I get the build system working, I'll be able to mantain the current structure but just publish the concatenated file which should make it compatible with the dev build syntaxes. |
@borela I'm still getting this using stable 3.1.1, Build 3176. Will this be fixed soon? |
The Java syntax has the same problem. I never edit Java in sublime text, but now Sublime Merge is giving me the same error if I work with a Java file. |
As a workaround you can disable unused packages. I disabled most of built-in ones (about 27) and this problem with 25000 limit is gone for me, and Markdown syntax works for me then. |
Could I have a status of this bug? :) I'm looking for a workaround. |
I have this problem with |
(this is a fast solution, I've not the level to debug all the syntax file, I prefere to remove lines which not work) If you want to fix markdown, in Should work fine after that: fenced-code-block:
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:xml))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.xml.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:text.xml
embed_scope: markup.raw.code-fence.xml.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.xml.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:sql))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.sql.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.sql
embed_scope: markup.raw.code-fence.sql.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.sql.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:graphviz))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.graphviz.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.dot
embed_scope: markup.raw.code-fence.graphviz.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.graphviz.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:javascript|js))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.javascript.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.js
embed_scope: markup.raw.code-fence.javascript.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.javascript.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:json))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.json.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.json
embed_scope: markup.raw.code-fence.json.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.json.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:csharp|c\#|cs))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.csharp.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.cs
embed_scope: markup.raw.code-fence.csharp.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.csharp.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:rust))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.rust.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.rust
embed_scope: markup.raw.code-fence.rust.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.rust.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:shell-script|sh|bash|zsh))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.shell-script.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.shell.bash
embed_scope: markup.raw.code-fence.shell-script.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.shell-script.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:php|inc))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.php.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.php
embed_scope: markup.raw.code-fence.php.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.php.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:rscript|r|splus))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.r.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.r
embed_scope: markup.raw.code-fence.r.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.r.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:golang))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.go.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.go
embed_scope: markup.raw.code-fence.go.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.go.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:ruby|rb|rbx))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.ruby.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.ruby
embed_scope: markup.raw.code-fence.ruby.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.ruby.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:objc|obj-c|objectivec|objective-c))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.objc.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.objc
embed_scope: markup.raw.code-fence.objc.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.objc.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:objc\+\+|obj-c\+\+|objectivec\+\+|objective-c\+\+))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.objc++.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.objc++
embed_scope: markup.raw.code-fence.objc++.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.objc++.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:c))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.c.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.c
embed_scope: markup.raw.code-fence.c.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.c.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:c\+\+|cpp))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.c++.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.c++
embed_scope: markup.raw.code-fence.c++.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.c++.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
((?i:regexp|regex))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.regexp.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:source.regexp
embed_scope: markup.raw.code-fence.regexp.markdown-gfm
escape: '{{code_fence_escape}}'
escape_captures:
0: meta.code-fence.definition.end.regexp.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
- match: |-
(?x)
{{fenced_code_block_start}}
([\w-]*) # any number of word characters or dashes
.*$\n? # all characters until EOL
captures:
0: meta.code-fence.definition.begin.text.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
push:
- meta_content_scope: markup.raw.code-fence.markdown-gfm
- match: '{{code_fence_escape}}'
captures:
0: meta.code-fence.definition.end.text.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
pop: true |
This issue is very annoying, I cannot use javascript in my markdown. Is there anybody working on it currently ? I would like to not have to monkeypatch my plugins. |
The ST4 beta includes many improvements, and handles JS quite well in Markdown using just the default packages. If you are a licensed user you can visit the Discord server to get access. |
Like @paullaffitte I'm really looking for this to be fixed! 👀 |
Hi,
as soon as I enable the Naomi package I get bombarded by multiple error windows like this and the corresponding syntax highlightings stop working:
In order to get back syntax highlighting for LaTeX and Markdown files I have to disable the Naomi package.
Unfortunately, I could not find any additional information in the Sublime Text Console. :(
The text was updated successfully, but these errors were encountered: