Skip to content

Commit

Permalink
Avoid deadlock when creating a new AsciiDoc file (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Dec 27, 2023
1 parent 90eed03 commit 6985068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This document provides a high-level view of the changes introduced by release.
[[releasenotes]]
== Release notes

=== 0.41.6

- Avoid deadlock when creating a new AsciiDoc file (#1502)

=== 0.41.5

- Bump org.asciidoctor:asciidoctorj from 2.5.10 to 2.5.11 (#1499)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
return createEditorAsync(project, file).build();
// called from create file from template
FileEditor first = myFirstProvider.createEditor(project, file);
FileEditor second = mySecondProvider.createEditor(project, file);
return createSplitEditor(first, second);
}

@NotNull
Expand Down Expand Up @@ -135,15 +138,9 @@ private static Builder getBuilderFromEditorProvider(@NotNull final FileEditorPro
@NotNull final VirtualFile file) {
if (provider instanceof AsyncFileEditorProvider) {
if (ApplicationManager.getApplication().isDispatchThread()) {
if (ApplicationManager.getApplication().isWriteAccessAllowed()) {
// called from create file from template
return CoroutinesKt.runBlockingMaybeCancellable((coroutineScope, continuation) ->
((AsyncFileEditorProvider) provider).createEditorBuilder(project, file, null, continuation));
} else {
// called from a structure view builder without a write lock
return TasksKt.runWithModalProgressBlocking(project, "Opening " + file.getName(), (coroutineScope, continuation) ->
((AsyncFileEditorProvider) provider).createEditorBuilder(project, file, null, continuation));
}
// called from a structure view builder without a write lock in 2023.3 pre-release, doesn't seem to be the case in 2023.3 final
return TasksKt.runWithModalProgressBlocking(project, "Opening " + file.getName(), (coroutineScope, continuation) ->
((AsyncFileEditorProvider) provider).createEditorBuilder(project, file, null, continuation));
} else {
// called from project view
return CoroutinesKt.runBlockingMaybeCancellable((coroutineScope, continuation) ->
Expand Down

0 comments on commit 6985068

Please sign in to comment.