Skip to content
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

Crashing when run on not popular languages (e.g. gleam) #133

Open
wczyz opened this issue Oct 10, 2024 · 2 comments
Open

Crashing when run on not popular languages (e.g. gleam) #133

wczyz opened this issue Oct 10, 2024 · 2 comments

Comments

@wczyz
Copy link

wczyz commented Oct 10, 2024

  1. Create main.gleam file
  2. Fill it with:
pub fn main() {
    
}
  1. Save file
  2. Select all lines and do :CodeSnap
  3. Crashes with:
thread '<unnamed>' panicked at library/core/src/panicking.rs:221:5:                                                                                                                                                                                            
panic in a function that cannot unwind                                                                                                                                                      
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                                         
unwinding panic. aborting.      
  • Works for other languages: C++, Python
  • Using packer
  • Compiled from source
  • Arch-linux
@VoxelMC
Copy link

VoxelMC commented Oct 16, 2024

I came here specifically to also ask for Gleam support. It's a pretty language to share!

@rbobillot
Copy link

rbobillot commented Dec 21, 2024

I'll take a closer look asap,
but for now, here's what I found:

  • Gleam is not yet handled by syntect (and adding support for new langs seems to be tricky): Curated list of languages trishume/syntect#168
  • the way the syntax detection is done, might lead to a panic:
    let syntax = match &self.extension {
    Some(extension) => syntax_set
    .find_syntax_by_extension(&extension)
    .ok_or(RenderError::HighlightCodeFailed(extension.to_string()))?,
    None => syntax_set
    .find_syntax_for_file(&self.code_file_path)
    .map_err(|_| RenderError::NoSuchFile(self.code_file_path.to_string()))?
    .ok_or(RenderError::HighlightCodeFailed(
    self.code_file_path.to_string(),
    ))?,
    };
    // The Syntect clearly distinguish between PHP and PHP Source
    // Should use PHP as highlight language if the source content contains "<php" tag
    // Should use PHP Source as highlight language if the source content not contains "<php" tag
    if let Some(identifier) = self.highlighting_language_source_map.get(&syntax.name[..]) {
    if !self.content.contains(identifier) {
    return Ok(syntax_set
    .find_syntax_by_name(&format!("{} Source", &syntax.name))
    .unwrap_or(syntax)
    .to_owned());
    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants