From 313dbb2033677678a192ab99857757f098d78783 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Thu, 21 Aug 2025 09:06:52 +0300 Subject: [PATCH] [terminal] IJPL-180524 Edit terminal PSI element check Avoid calling `getNode()` because it may cause loading AST for stubbed PSI elements, which is slow. GitOrigin-RevId: 80774355978c59732f8d9b7e9695d72ae4c04e19 --- .../intellij/terminal/frontend/TerminalTextSelectioner.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/TerminalTextSelectioner.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/TerminalTextSelectioner.kt index bc9526960093..405486ed73bf 100644 --- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/TerminalTextSelectioner.kt +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/TerminalTextSelectioner.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.Condition import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement +import com.intellij.psi.impl.source.tree.LeafPsiElement import org.jetbrains.plugins.terminal.block.reworked.lang.TerminalOutputLanguage /** @@ -59,6 +60,7 @@ internal class TerminalWordSelectionFilter : Condition { } private fun isTerminalPsiElement(e: PsiElement): Boolean { - // e.language can be also used there, but it might be more expensive when the language is not terminal - return e.node?.elementType?.language == TerminalOutputLanguage + // the single `e.language` condition is enough, but it might be more expensive + // because psi element implementations may compute the language differently. + return e is LeafPsiElement && e.language == TerminalOutputLanguage } \ No newline at end of file