KTNB, DS: Turn off folding for injected code in Kotlin Notebooks

GitOrigin-RevId: bde88dafffe1d26ac8358413452f1508b8512499
This commit is contained in:
Ilya Muradyan
2021-10-06 01:09:22 +00:00
committed by intellij-monorepo-bot
parent 9a764784ea
commit 2bc48a119f
@@ -44,6 +44,8 @@ public final class FoldingUpdate {
private static final Key<CachedValue<Runnable>> CODE_FOLDING_KEY = Key.create("code folding");
public static final Key<Boolean> INJECTED_CODE_FOLDING_ENABLED = Key.create("injected code folding is enabled");
private FoldingUpdate() {
}
@@ -130,6 +132,10 @@ public final class FoldingUpdate {
@Nullable
public static Runnable updateInjectedFoldRegions(@NotNull final Editor editor, @NotNull final PsiFile file, final boolean applyDefaultState) {
if (file instanceof PsiCompiledElement) return null;
final Boolean codeFoldingEnabled = editor.getUserData(INJECTED_CODE_FOLDING_ENABLED);
if (codeFoldingEnabled != null && !codeFoldingEnabled) {
return null;
}
ApplicationManager.getApplication().assertReadAccessAllowed();
final Project project = file.getProject();