From 7d85738d7b7ae6278c3d2b21a0d9a8d06190d2c6 Mon Sep 17 00:00:00 2001 From: Timur Aliberdov Date: Mon, 23 Dec 2024 18:44:51 +0100 Subject: [PATCH] [code with me] fix import quickfixes availability #SCL-19639 fixed --- .../autoImport/quickFix/ScalaImportElementFix.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scala/scala-impl/src/org/jetbrains/plugins/scala/autoImport/quickFix/ScalaImportElementFix.scala b/scala/scala-impl/src/org/jetbrains/plugins/scala/autoImport/quickFix/ScalaImportElementFix.scala index 63bc630cb7d..0912394d1f6 100644 --- a/scala/scala-impl/src/org/jetbrains/plugins/scala/autoImport/quickFix/ScalaImportElementFix.scala +++ b/scala/scala-impl/src/org/jetbrains/plugins/scala/autoImport/quickFix/ScalaImportElementFix.scala @@ -5,11 +5,12 @@ import com.intellij.codeInsight.hint.HintManagerImpl import com.intellij.codeInsight.intention.PriorityAction import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo import com.intellij.codeInspection.HintAction +import com.intellij.codeWithMe.ClientId import com.intellij.idea.AppMode import com.intellij.model.SideEffectGuard.SideEffectNotAllowedException import com.intellij.openapi.application.{ApplicationManager, ReadAction} import com.intellij.openapi.components.Service -import com.intellij.openapi.editor.{Editor, LogicalPosition} +import com.intellij.openapi.editor.{ClientEditorManager, Editor, LogicalPosition} import com.intellij.openapi.project.Project import com.intellij.openapi.util.{ModificationTracker, TextRange} import com.intellij.psi.{PsiElement, PsiFile} @@ -229,8 +230,11 @@ private object ScalaImportElementFix { place.getTextRange.grown(1).contains(editor.getCaretModel.getOffset) def visibleRange: TextRange = { - // There is no meaningful visible range for RemoteDev backend - if (AppMode.isRemoteDevHost) { + // 1. There is no meaningful visible range for RemoteDev backend + // 2. For non-local editor its visible area is unreliable + // (see IJPL-163871 Intentions sometimes don't appear in Remote Dev and Code With Me) + // (see SCL-19639 Code With Me: Auto-import quick-fix is offered only after some code editing on host) + if (AppMode.isRemoteDevHost || !ClientId.isLocal(ClientEditorManager.getClientId(editor))) { return TextRange.create(0, editor.getDocument.getTextLength) }