krasa / GrepConsole

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7125
Apache License 2.0
428 stars 57 forks source link

do not replace original ClearConsoleAction in MyConsoleActionsPostProcessor #260

Closed unkarjedy closed 1 year ago

unkarjedy commented 1 year ago

Describe the bug See this code replaceClearAction(anActions); It uses custom implementation of ClearConsoleAction which seems to be added to collect statistics. This leads to a bug when in some consoles "Clear" button is not active. See https://youtrack.jetbrains.com/issue/SCL-19370

To Reproduce Steps to reproduce the behavior:

  1. Install Scala Plugin
  2. Open sbt shell (View | Tool Windows | sbt shell
  3. See that "Clear All" button is disabled

Expected behavior "Clear" button is enabled

Implementation details ClearConsoleAction implementation should not try to search console view here. ConsoleView console instance is already available, you can just pass it via constructor. See com.intellij.execution.impl.ConsoleViewImpl.ClearThisConsoleAction for an example, your implementation should be based on it.

Anyway, replacing default "clear console" action for all consoles for sake of statistics is a bad use of API (or lack of proper API and overuse of implementation detail). The best would be to remove replaceClearAction(anActions); completely

Environment : Scala Plugin : 2023.1.13 IntelliJ IDEA 2023.1 RC (Ultimate Edition) Build : IU-231.8109.156 March 25, 2023 JRE : 17.0.6+10-b829.5amd64 (OpenJDK 64-Bit Server VM JetBrains s.r.o.) OS : Windows (10.0, amd64) Project JDK : Oracle OpenJDK version 17.0.1 Server JDK : Oracle OpenJDK version 17.0.1