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 1 commit
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 @@ -77,6 +77,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265)
- We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590)
- 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)

### Removed

Expand Down
31 changes: 27 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 @@ -27,13 +27,36 @@ 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");
System.out.println(progFiles);
Copy link
Member

Choose a reason for hiding this comment

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

Probably a left over from debugging. If you need debug output use LOGGER.debug(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

emmm,I was too careless. Thanks for your suggestion!

programPath = getProgramPath(programName, directoryName, progFiles);
if (programPath != null) {
return programPath;
}

return "";
}

private String getProgramPath(String programName, String directoryName, String progFiles) {
String 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).toString();
} else {
programPath = Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
}
File program = new File(programPath);
Copy link
Member

Choose a reason for hiding this comment

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

You can use Files.exist(path)

if (program.exists()) {
return programPath;
}
return Path.of(progFiles, programName + DEFAULT_EXECUTABLE_EXTENSION).toString();
return null;
}

@Override
Expand Down