Skip to content

Commit

Permalink
#6687: Uncaught Exception java.lang.NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmingliang-ms committed Sep 21, 2022
1 parent 9220142 commit eb033d6
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.messages.MessageBusConnection;
Expand Down Expand Up @@ -135,7 +136,7 @@ private boolean openFileInEditor(final Consumer<? super String> contentSaver, Vi
public void beforeFileClosed(FileEditorManager source, VirtualFile file) {
try {
final String content = getTextEditorContent((TextEditor) fileEditor);
if (file == virtualFile && !StringUtils.equals(content, originContent)) {
if (Objects.equals(file, virtualFile) && !StringUtils.equals(content, originContent)) {
final boolean result = AzureMessager.getMessager().confirm(SAVE_CHANGES, APP_SERVICE_FILE_EDITING);
if (result) {
contentSaver.consume(content);
Expand Down Expand Up @@ -226,7 +227,12 @@ private synchronized VirtualFile getOrCreateVirtualFile(final AppServiceFile fil

@SneakyThrows
private LightVirtualFile createVirtualFile(final String fileId, final String fullName, FileEditorManager manager) {
final LightVirtualFile virtualFile = new LightVirtualFile(fullName);
final LightVirtualFile virtualFile = new LightVirtualFile(fullName) {
@Override
public VirtualFile getParent() {
return VirtualFileManager.getInstance().findFileByNioPath(FileUtils.getTempDirectory().toPath());
}
};
virtualFile.setFileType(FileTypeManager.getInstance().getFileTypeByFileName(fullName));
virtualFile.setCharset(StandardCharsets.UTF_8);
virtualFile.putUserData(APP_SERVICE_FILE_ID, fileId);
Expand Down

0 comments on commit eb033d6

Please sign in to comment.