Skip to content

Commit

Permalink
Fix a small oversight with absolute paths
Browse files Browse the repository at this point in the history
This should address #3.

Also fixes an NPE for the run configuration page.
  • Loading branch information
ab5tract committed Sep 21, 2024
1 parent bfceb0c commit 40b5a8a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/org/raku/comma/run/RakuRunSettingsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,21 @@ protected void applyEditorTo(@NotNull RakuRunConfiguration conf) throws Configur
String fileLine = fileField.getText();
if (Objects.equals(fileLine, "")) throw new ConfigurationException("Main script path is absent");

String workingDir = myParams.getWorkingDirectoryAccessor().getText();
if (workingDir.endsWith("/")) {
workingDir = workingDir.substring(0, workingDir.length() - 1);
}

VirtualFile file = LocalFileSystem.getInstance().findFileByPath(workingDir + "/" + fileLine);
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fileLine);
if (file == null || !file.exists()) {
VirtualFile revisedPath = LocalFileSystem.getInstance().findFileByPath(workingDir + "/" + fileLine);
if (revisedPath == null || !revisedPath.exists()) {
throw new ConfigurationException("Main script path is incorrect");
String workingDir = myParams.getWorkingDirectoryAccessor().getText();
if (workingDir.endsWith("/")) {
workingDir = workingDir.substring(0, workingDir.length() - 1);
}
file = LocalFileSystem.getInstance().findFileByPath(workingDir + "/" + fileLine);
}
if (file == null || !file.exists()) {
throw new ConfigurationException("Main script path is incorrect");
} else {
conf.setScriptPath(fileLine);
}

conf.setDebugPort(Integer.parseInt(myDebugPort.getText()));
conf.setStartSuspended(toStartSuspended.isSelected());
conf.setInterpreterParameters(myRakuParametersPanel.getText());
Expand Down Expand Up @@ -138,8 +139,7 @@ public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
myParams = new CommonProgramParametersPanel() {
private LabeledComponent<?> myFileComponent;
private LabeledComponent<RawCommandLineEditor> myRakuParametersComponent;
private final Predicate<Component> panelPredicate = component -> component instanceof JComponent
&& component instanceof PanelWithAnchor;
private Predicate<Component> panelPredicate;

@Override
protected void addComponents() {
Expand Down Expand Up @@ -183,6 +183,8 @@ public Component getListCellRendererComponent(JList<? extends String> list,
LabeledComponent<?> logTimelineComponent = LabeledComponent.create(myLogTimelineOptions,
"Log::Timeline events",
BorderLayout.WEST);

panelPredicate = component -> component instanceof JComponent && component instanceof PanelWithAnchor;
add(logTimelineComponent);
}

Expand Down

0 comments on commit 40b5a8a

Please sign in to comment.