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

Includegraphics resiliency and file extension case de-sensitivity #3145

Merged
merged 6 commits into from
Jul 10, 2023

Conversation

jojo2357
Copy link
Contributor

@jojo2357 jojo2357 commented Jul 5, 2023

Fix #3142

Added jpeg, and allow JPG, JPg and such to be valid.

Why though, does

override fun matchesName(fileName: String): Boolean {
return pattern!!.matcher(fileName.lowercase(Locale.getDefault())).matches()
}
override fun matchesExtension(extension: String): Boolean {
return supportedExtensions.contains(extension)
}
have zero usages?

I have no idea how to use the already implemented commands, so i did some jank in order to get it to work, please fix
https://github.com/jojo2357/TeXiFy-IDEA/blob/a15853ff8736c5b434546edb677cbe8c50affacf/src/nl/hannahsten/texifyidea/reference/InputFileReference.kt#L169

Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://tex.stackexchange.com/questions/469734/which-file-does-includegraphics-select-if-there-are-multiple-files-with-differen \includegraphics just tries a list of extensions one by one. Why not do that as well (extending the hardcoded list), instead of this case insensitivity mess?

@jojo2357
Copy link
Contributor Author

jojo2357 commented Jul 6, 2023

Oh yes please.

Hence why i made only a draft pr.

What if we made it tell you specifically that an extension is not valid (instead of file.pdf is missing) and also a warning when multiple candidates are found (ex all of .png .jpg etc exist)?

Maybe thats beyond the scope of this issue but it sounds like a cool feature.

@jojo2357 jojo2357 force-pushed the imageExtensionFix branch from a15853f to 4c559ea Compare July 7, 2023 01:36
@jojo2357
Copy link
Contributor Author

jojo2357 commented Jul 7, 2023

I pushed with great force, and now all that gross code is gone!

@jojo2357 jojo2357 marked this pull request as ready for review July 7, 2023 01:37
@PHPirates
Copy link
Collaborator

What if we made it tell you specifically that an extension is not valid (instead of file.pdf is missing) and also a warning when multiple candidates are found (ex all of .png .jpg etc exist)?

Maybe thats beyond the scope of this issue but it sounds like a cool feature.

Yeah we could make a 'maybe you meant this file instead' quickfix, that would be really nice.
But I don't think we even support \DeclareGraphicsExtensions yet, which sounds more important.

@jojo2357
Copy link
Contributor Author

jojo2357 commented Jul 7, 2023

But I don't think we even support \DeclareGraphicsExtensions yet, which sounds more important.

That sounds out of the scope of this PR and while I agree, i think it should be covered in a separate pr

jojo2357 added 3 commits July 7, 2023 02:00
This allows us to search for files with a biased order to our search
@jojo2357
Copy link
Contributor Author

jojo2357 commented Jul 8, 2023

One test fails locally. LatexInclusionLoopInspectionTest#testIncludingPackage. Because all the extension stuff runs on lists, and tex comes before sty, there is no safeguard to specifically prefer sty in some cases.

@jojo2357 jojo2357 requested a review from PHPirates July 8, 2023 17:45
@PHPirates
Copy link
Collaborator

One test fails locally. LatexInclusionLoopInspectionTest#testIncludingPackage. Because all the extension stuff runs on lists, and tex comes before sty, there is no safeguard to specifically prefer sty in some cases.

Exactly, so I switched the order

Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@PHPirates PHPirates changed the title Includegraphics resilliency and file extension case de-sensitivity Includegraphics resiliency and file extension case de-sensitivity Jul 9, 2023
@jojo2357
Copy link
Contributor Author

Merge?

@PHPirates PHPirates merged commit bf3e5f0 into Hannah-Sten:master Jul 10, 2023
@PHPirates PHPirates added this to the b0.7.32 milestone Jul 10, 2023
@jojo2357 jojo2357 deleted the imageExtensionFix branch July 10, 2023 18:06
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.

jpeg file not found, but jpg does get found
2 participants