mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-25 00:14:49 +01:00
fix: check if folder exists before trying to create it
This commit is contained in:
parent
db89c781a6
commit
7995b8db45
2 changed files with 6 additions and 2 deletions
|
@ -47,8 +47,11 @@ public class FileUtil {
|
||||||
if(found == null) {
|
if(found == null) {
|
||||||
VirtualFile lastParent = contentRoot;
|
VirtualFile lastParent = contentRoot;
|
||||||
String[] path = bufferName.split("/");
|
String[] path = bufferName.split("/");
|
||||||
for(int i = 0; i < path.length - 1; i++)
|
for(int i = 0; i < path.length - 1; i++) {
|
||||||
lastParent = lastParent.createChildDirectory(requestor, path[i]);
|
VirtualFile current = lastParent.findChild(path[i]);
|
||||||
|
if(current == null) current = lastParent.createChildDirectory(requestor, path[i]);
|
||||||
|
lastParent = current;
|
||||||
|
}
|
||||||
found = lastParent.createChildData(requestor, path[path.length - 1]);
|
found = lastParent.createChildData(requestor, path[path.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class BufferCallback implements Consumer<BufferController> {
|
||||||
() -> changeList.forEach((change) -> {
|
() -> changeList.forEach((change) -> {
|
||||||
editor.getDocument().replaceString((int) change.start, (int) change.end, change.content);
|
editor.getDocument().replaceString((int) change.start, (int) change.end, change.content);
|
||||||
// check for validity, force-sync if mismatch
|
// check for validity, force-sync if mismatch
|
||||||
|
// TODO: prompt instead of doing it silently
|
||||||
if(change.hash.isPresent() && change.hash.getAsLong() != Extensions.hash(editor.getDocument().getText())) {
|
if(change.hash.isPresent() && change.hash.getAsLong() != Extensions.hash(editor.getDocument().getText())) {
|
||||||
try {
|
try {
|
||||||
editor.getDocument().setText(bufferController.getContent());
|
editor.getDocument().setText(bufferController.getContent());
|
||||||
|
|
Loading…
Reference in a new issue