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

Fix for issue 7641: Wrong path to TeXstudio #7664

Merged
merged 4 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with opacity of disabled icon-buttons [#7195](https://github.com/JabRef/jabref/issues/7195)
- We fixed an issue where journal abbreviations in UTF-8 were not recognized [#5850](https://github.com/JabRef/jabref/issues/5850)
- We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633)
- We fixed an issue with the default path of external application. [#7641](https://github.com/JabRef/jabref/issues/7641)
- We fixed an issue where urls must be embedded in a style tag when importing EndNote style Xml files. Now it can parse url with or without a style tag. [#6199](https://github.com/JabRef/jabref/issues/6199)
- We fixed an issue where the article title with colon fails to download the arXiv link (pdf file). [#7660](https://github.com/JabRef/issues/7660)

Expand Down
30 changes: 26 additions & 4 deletions src/main/java/org/jabref/gui/desktop/os/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;

Expand All @@ -27,13 +28,34 @@ public void openFile(String filePath, String fileType) throws IOException {
@Override
public String detectProgramPath(String programName, String directoryName) {
String progFiles = System.getenv("ProgramFiles(x86)");
if (progFiles == null) {
progFiles = System.getenv("ProgramFiles");
String programPath;
if (progFiles != null) {
programPath = getProgramPath(programName, directoryName, progFiles);
if (programPath != null) {
return programPath;
}
}

progFiles = System.getenv("ProgramFiles");
programPath = getProgramPath(programName, directoryName, progFiles);
if (programPath != null) {
return programPath;
}

return "";
}

private String getProgramPath(String programName, String directoryName, String progFiles) {
Path programPath;
if ((directoryName != null) && !directoryName.isEmpty()) {
return Path.of(progFiles, directoryName, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
programPath = Path.of(progFiles, directoryName, programName + DEFAULT_EXECUTABLE_EXTENSION);
} else {
programPath = Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION);
}
if (Files.exists(programPath)) {
return programPath.toString();
}
return Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
return null;
}

@Override
Expand Down