From 13643996dc6893a15ff7dafc8893661e38c64821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Thu, 8 May 2025 15:52:29 +0200 Subject: [PATCH] editors.md: active editor --- topics/basics/faq.md | 1 - topics/reference_guide/editors.md | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/topics/basics/faq.md b/topics/basics/faq.md index f7e649939..3fa9d53a0 100644 --- a/topics/basics/faq.md +++ b/topics/basics/faq.md @@ -41,7 +41,6 @@ for programmatic registration. * [Can I open an editor which has no underlying file on disk?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206135449-Create-an-Editor-for-a-non-physical-file) * [How do I highlight elements in a source code editor?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206143909-MarkupModel-navigate-highlighted-elements) * [How do I allow to navigate between highlighted elements using Find Next?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206143879-HighlightManager-how-to-enable-F3-functionality) -* [How do I get the active editor instance?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206141119-how-to-get-the-Editor-from-PsiElement-) * [How do I clear the read-only status of a file?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206142039-Clear-read-only-status) * [How can I show an editor with error highlighting in a tool window?](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206146679-Error-highlighting-in-Editors) diff --git a/topics/reference_guide/editors.md b/topics/reference_guide/editors.md index 5d988bdea..ac6e92c87 100644 --- a/topics/reference_guide/editors.md +++ b/topics/reference_guide/editors.md @@ -8,3 +8,13 @@ This section covers working with text in the IntelliJ Platform editor. * [](editor_basics.md) * [](text_selection.md) * [](multiple_carets.md) + +## Editors FAQ + +### How do I get the active editor instance? + +Current select editor(s) can be queried from [`FileEditorManager`](%gh-ic%/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java). + +From an [Action's `DataContext`](action_system.md#determining-the-action-context), use [`CommonDataKeys.EDITOR`](%gh-ic%/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java). + +For a given PSI Element, use [`PsiEditorUtil.findEditor()`](%gh-ic%/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java)