[Fix::syntax] avoid filesystem access when guessing syntax#125
Open
MARLENELASSEINPHOTOMACHEN wants to merge 1 commit into
Open
[Fix::syntax] avoid filesystem access when guessing syntax#125MARLENELASSEINPHOTOMACHEN wants to merge 1 commit into
MARLENELASSEINPHOTOMACHEN wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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