[terminal] IJPL-157806 Add registry to disable autocomplete in terminal prompt

GitOrigin-RevId: a81185c771fe4d35b7402cd9a745deee9e2fe214
This commit is contained in:
Vladimir Shefer
2024-07-17 13:47:52 +02:00
committed by intellij-monorepo-bot
parent a9ef8a4f1c
commit c4f981882a
4 changed files with 17 additions and 0 deletions

View File

@@ -35,6 +35,8 @@
description="Whether to show the GotIt tooltip with a proposal to try the New Terminal"/>
<registryKey key="terminal.new.ui.inline.completion" defaultValue="false"
description="Whether to show the inline (grey text) completion in the New Terminal"/>
<registryKey key="terminal.new.ui.autocompletion" defaultValue="true"
description="Whether to run autocompletion in the New Terminal"/>
<experimentalFeature id="terminal.shell.command.handling" percentOfUsers="100"/>
<terminal.shellCommandHandler implementation="org.jetbrains.plugins.terminal.RunAnythingTerminalBridge"/>

View File

@@ -44,6 +44,7 @@ open class LocalBlockTerminalRunner(project: Project) : LocalTerminalDirectRunne
const val BLOCK_TERMINAL_POWERSHELL_WIN11_REGISTRY: String = "terminal.new.ui.powershell.win11"
const val BLOCK_TERMINAL_POWERSHELL_WIN10_REGISTRY: String = "terminal.new.ui.powershell.win10"
const val BLOCK_TERMINAL_POWERSHELL_UNIX_REGISTRY: String = "terminal.new.ui.powershell.unix"
const val BLOCK_TERMINAL_AUTOCOMPLETION: String = "terminal.new.ui.autocompletion"
private const val BLOCK_TERMINAL_SHOW_PROMOTION: String = "terminal.new.ui.show.promotion"
}
}

View File

@@ -8,6 +8,7 @@ import com.intellij.openapi.progress.runBlockingCancellable
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.util.text.StringUtil
import com.intellij.platform.diagnostic.telemetry.Scope
import com.intellij.platform.diagnostic.telemetry.TelemetryManager
@@ -18,6 +19,7 @@ import com.intellij.terminal.completion.ShellDataGeneratorsExecutor
import com.intellij.terminal.completion.ShellRuntimeContextProvider
import com.intellij.terminal.completion.spec.ShellCompletionSuggestion
import com.intellij.terminal.completion.spec.ShellSuggestionType
import org.jetbrains.plugins.terminal.LocalBlockTerminalRunner.Companion.BLOCK_TERMINAL_AUTOCOMPLETION
import org.jetbrains.plugins.terminal.action.TerminalCommandCompletionAction
import org.jetbrains.plugins.terminal.block.completion.TerminalCompletionUtil.findIconForSuggestion
import org.jetbrains.plugins.terminal.block.completion.TerminalCompletionUtil.getNextSuggestionsString
@@ -49,6 +51,11 @@ internal class TerminalCommandSpecCompletionContributor : CompletionContributor(
return
}
if (parameters.isAutoPopup && !Registry.`is`(BLOCK_TERMINAL_AUTOCOMPLETION)) {
result.stopHere()
return
}
if (parameters.editor.getUserData(TerminalCommandCompletionAction.SUPPRESS_COMPLETION) == true) {
result.stopHere()
return

View File

@@ -10,7 +10,9 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.progress.runBlockingCancellable
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.registry.Registry
import com.intellij.util.DocumentUtil
import org.jetbrains.plugins.terminal.LocalBlockTerminalRunner.Companion.BLOCK_TERMINAL_AUTOCOMPLETION
import org.jetbrains.plugins.terminal.TerminalIcons
import org.jetbrains.plugins.terminal.block.completion.spec.impl.ShellDataGeneratorsExecutorImpl
import org.jetbrains.plugins.terminal.block.completion.spec.impl.ShellRuntimeContextProviderImpl
@@ -33,6 +35,11 @@ internal class PowerShellCompletionContributor : CompletionContributor(), DumbAw
return
}
if (parameters.isAutoPopup && !Registry.`is`(BLOCK_TERMINAL_AUTOCOMPLETION)) {
result.stopHere()
return
}
// stop even if we can't suggest something to not execute contributors from the ShellScript plugin
result.stopHere()
if (session.shellIntegration.shellType != ShellType.POWERSHELL) {