From 1051f5cabc09d43d0f48e77d377b853a081c4af5 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Wed, 23 Oct 2024 17:36:54 +0300 Subject: [PATCH] IJOB-569 Fix 'The editor has been closed' warning in Declaration and Usages lesson Do not use `editor` property from the runtime context because it can throw an exception (and then warning in the Learn panel) if currently selected editor is null. Because of the platform implementation, selected editor can be null at the moment between switching the editor tabs. (cherry picked from commit dc3afe43eb8be4ff8e7993a0da35093577e2f118) IJ-CR-147744 GitOrigin-RevId: 37571fa1905b762c6e3c8b2d6bad09ce9af6fdbb --- .../lesson/general/navigation/DeclarationAndUsagesLesson.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ide-features-trainer/src/training/learn/lesson/general/navigation/DeclarationAndUsagesLesson.kt b/plugins/ide-features-trainer/src/training/learn/lesson/general/navigation/DeclarationAndUsagesLesson.kt index 27dcfd4d7585..980143d44075 100644 --- a/plugins/ide-features-trainer/src/training/learn/lesson/general/navigation/DeclarationAndUsagesLesson.kt +++ b/plugins/ide-features-trainer/src/training/learn/lesson/general/navigation/DeclarationAndUsagesLesson.kt @@ -52,7 +52,7 @@ abstract class DeclarationAndUsagesLesson task("GotoDeclaration") { actionId -> text(LessonsBundle.message("declaration.and.usages.show.usages", action(actionId))) stateCheck l@{ - val curEditor = editor + val curEditor = FileEditorManager.getInstance(project).selectedTextEditor ?: return@l false val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(curEditor.document) ?: return@l false val offset = curEditor.caretModel.offset val element = psiFile.findElementAt(offset) ?: return@l false