amp icon indicating copy to clipboard operation
amp copied to clipboard

amp crashes with only some files when using vue syntax highlighting

Open pbgc opened this issue 5 years ago • 6 comments

Hi!

I use amp several sublime text .sublime-syntax files (for formats not supported out of the box) that I collected. One is for vuejs .vue files that always worked ... except for a file. With this particular file amp crashes! I cannot see the error message because it disappears too fast. The same file and same syntax works with sublime (I tried before submitting this issue).

Don't know if the problem is caused by the syntax having some problems in the definition ... but maybe amp should not crash or at least should give a meaningful message.

I attach the syntax file and a file that when edited gives the problem (you have to scroll until reaching the styles) if you want to check it up. If not please close the issue :)

files.zip

Thanks in advance and thanks again for you great work on amp

Pedro

pbgc avatar Sep 20 '19 14:09 pbgc

It happened today with a .ts file

pbgc avatar Nov 19 '19 20:11 pbgc

attached a zip with the syntax file and a ts file that crashes amp. The file opens correctly in Sublime ts_probs.zip

pbgc avatar Nov 19 '19 21:11 pbgc

Thanks for submitting this, @pbgc! The underlying syntax highlighting library uses a lot of unwrap calls that can cause a panic at runtime. I started down the path of adding proper error handling, but didn't get it far enough to land a PR. I'll have a look at this again.

jmacdonald avatar Nov 25 '19 02:11 jmacdonald

thread 'main' panicked at 'Can only call resolve on linked references: ByScope { scope: <source.scss>, sub_context: None }', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/syntect-2.1.0/src/parsing/syntax_definition.rs:205:18 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

Looks like there's an explicit "TODO" to fix that here. From what it seems like, there's an invalid regex in that syntax definition.

If ever amp does this, you can capture the error output like so:

amp path_to_file 2> errors

which will redirect any stderr output to an errors file.

jmacdonald avatar Nov 25 '19 02:11 jmacdonald

@jmacdonald thanks for the answer. The typescript i sent after file gives:

thread 'main' panicked at 'begin <= end (13 <= 0) when slicing declare const jQuery; ', src/libcore/str/mod.rs:2021:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

The two files open without problems in Sublime (from where I took the syntax files) so let's hope that syntect library work on those todo's and not panic

pbgc avatar Nov 25 '19 11:11 pbgc

This comment is relevant to people using amp to edit .mata files for Stata:

I experienced the above "Can only call resolve on linked references…" crash when opening a .mata file with amp. I was using the Stata syntax file from this repo. Reading the Stata.sublime-syntax file I noticed a reference to a Mata.sublime-syntax file. Adding this file (from that same repo) to amp's syntaxes directory fixed the crash.

multinormal avatar Aug 10 '21 08:08 multinormal

previous comment from @multinormal solved my problem. I also noticed references to other syntax's (scss, sass, etc). Including the needed files stopped the crashes.

pbgc avatar Jan 24 '24 11:01 pbgc