Skip to content

[Fix::syntax] avoid filesystem access when guessing syntax#125

Open
MARLENELASSEINPHOTOMACHEN wants to merge 1 commit into
codesnap-rs:mainfrom
MARLENELASSEINPHOTOMACHEN:fix/syntax-no-fs-access
Open

[Fix::syntax] avoid filesystem access when guessing syntax#125
MARLENELASSEINPHOTOMACHEN wants to merge 1 commit into
codesnap-rs:mainfrom
MARLENELASSEINPHOTOMACHEN:fix/syntax-no-fs-access

Conversation

@MARLENELASSEINPHOTOMACHEN
Copy link
Copy Markdown

Problem:
When snapshotting code from a path that syntect can't open, e.g. logical/display path, it fails on file lookup of extensions syntect doesn't know: RenderError::NoSuchFile

Encountered when snapping something.astro w codesnap.nvim -> codesnap.nvim passes display path (project/something.astro) -> dylib File::open resolves w cwd to /User/marlene/project/project/something.astro :(

Fix:
find_syntax_by_extension(file_name) - to match find_syntax_for_file()
find_syntax_by_extension(extension)
find_syntax_by_first_line(code) - instead of reading from disk

Also fixes: multi-language files like .astro when snapping a slice not in opening section (e.g. HTML in .astro): now lets first-line guessing match the slice itself - previously incorrect based on first line

thx

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

Successfully merging this pull request may close these issues.

1 participant