diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 27f270b20..62c10c06a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,7 @@ This document provides a high-level view of the changes introduced by release. - Quoted strings now highlighted with a background in the editor even if they contain single or double quotes - Disable off-screen-rendering if IDE's setting for off-screen-rendering is disabled (#1575) - Prevent exception when showing injected AsciiDoc content (#1576) +- Prevent change-outside-of-command exception when creating a preview for adding an ID to a section (#1577) === 0.41.9 diff --git a/doc/contributors-guide/modules/ROOT/pages/coder/debugging-and-logging.adoc b/doc/contributors-guide/modules/ROOT/pages/coder/debugging-and-logging.adoc index 3a997964c..0375c910f 100644 --- a/doc/contributors-guide/modules/ROOT/pages/coder/debugging-and-logging.adoc +++ b/doc/contributors-guide/modules/ROOT/pages/coder/debugging-and-logging.adoc @@ -3,7 +3,7 @@ IntelliJ will interrupt threads for better interactivity. The disadvantage is that this is also triggered when the developer debugs the plugin. -To disable this functionality find the action "`Disable ProcessCanceledException`" once the IDE has started. +To disable this functionality find the action "`Skip Window Deactivation Events`" ("`Disable ProcessCanceledException`" in 2023.1 and earlier) once the IDE has started. Each restart will reset the settings. To enable logging at debug and trace level the user (or developer) can change settings via menu:Help[Debug Log Settings] and enter (including the hash at the beginning) a logger name. diff --git a/src/main/java/org/asciidoc/intellij/quickfix/AsciiDocAddBlockIdToSection.java b/src/main/java/org/asciidoc/intellij/quickfix/AsciiDocAddBlockIdToSection.java index 382973f18..af7f35f3f 100644 --- a/src/main/java/org/asciidoc/intellij/quickfix/AsciiDocAddBlockIdToSection.java +++ b/src/main/java/org/asciidoc/intellij/quickfix/AsciiDocAddBlockIdToSection.java @@ -53,27 +53,23 @@ public AsciiDocAddBlockIdToSection(PsiElement element) { @Override public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) { - IntentionPreviewInfo intentionPreviewInfo = LocalQuickFix.super.generatePreview(project, previewDescriptor); - if (intentionPreviewInfo == IntentionPreviewInfo.EMPTY) { - PsiElement element = previewDescriptor.getPsiElement(); - AsciiDocSection section = ((HasAnchorReference) previewDescriptor.getPsiElement()).resolveAnchorForSection(); - if (section != null) { - if (section.getBlockId() == null) { - PsiElement firstChild = section.getFirstChild(); - String id = section.getAutogeneratedId(); - AsciiDocFileReference reference = ((HasAnchorReference) element).getAnchorReference(); - if (reference != null && !reference.isPossibleRefText()) { - id = reference.getRangeInElement().substring(element.getText()); - } - String origText = section.getContainingFile().getText(); - StringBuilder newText = new StringBuilder(origText); - newText.insert(firstChild.getTextOffset(), "[#" + id + "]\n"); - intentionPreviewInfo = - new IntentionPreviewInfo.CustomDiff(AsciiDocFileType.INSTANCE, section.getContainingFile().getName(), origText, newText.toString(), true); + PsiElement element = previewDescriptor.getPsiElement(); + AsciiDocSection section = ((HasAnchorReference) previewDescriptor.getPsiElement()).resolveAnchorForSection(); + if (section != null) { + if (section.getBlockId() == null) { + PsiElement firstChild = section.getFirstChild(); + String id = section.getAutogeneratedId(); + AsciiDocFileReference reference = ((HasAnchorReference) element).getAnchorReference(); + if (reference != null && !reference.isPossibleRefText()) { + id = reference.getRangeInElement().substring(element.getText()); } + String origText = section.getContainingFile().getText(); + StringBuilder newText = new StringBuilder(origText); + newText.insert(firstChild.getTextOffset(), "[#" + id + "]\n"); + return new IntentionPreviewInfo.CustomDiff(AsciiDocFileType.INSTANCE, section.getContainingFile().getName(), origText, newText.toString(), true); } } - return intentionPreviewInfo; + return IntentionPreviewInfo.EMPTY; } @Override