Merge pull request #628 from CocoTheOwner/reopenVSCodeOnFail

Try opening VSCode again after first time failed
This commit is contained in:
Dan 2021-09-11 07:50:37 -04:00 committed by GitHub
commit c2779570fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,30 @@ public class IrisProject {
return; return;
} }
File f = d.getLoader().getDataFolder(); File f = d.getLoader().getDataFolder();
if (!doOpenVSCode(f)) {
File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace");
Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace.");
try {
IO.writeAll(ff, createCodeWorkspaceConfig());
} catch (IOException e1) {
Iris.reportError(e1);
e1.printStackTrace();
}
updateWorkspace();
if (!doOpenVSCode(f)){
Iris.warn("Tried creating code workspace but failed a second time. Your project is likely corrupt.");
}
}
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
});
}
private boolean doOpenVSCode(File f) throws IOException {
boolean foundWork = false; boolean foundWork = false;
for (File i : Objects.requireNonNull(f.listFiles())) { for (File i : Objects.requireNonNull(f.listFiles())) {
if (i.getName().endsWith(".code-workspace")) { if (i.getName().endsWith(".code-workspace")) {
@ -195,24 +219,7 @@ public class IrisProject {
break; break;
} }
} }
return foundWork;
if (!foundWork) {
File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace");
Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace.");
try {
IO.writeAll(ff, createCodeWorkspaceConfig());
} catch (IOException e1) {
Iris.reportError(e1);
e1.printStackTrace();
}
updateWorkspace();
}
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
});
} }
public void open(VolmitSender sender, long seed, Consumer<World> onDone) throws IrisException { public void open(VolmitSender sender, long seed, Consumer<World> onDone) throws IrisException {