From 56838b8153fd3e7fd414e356ab25cca752fd5f05 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Wed, 29 May 2024 16:25:54 +0300 Subject: [PATCH 01/22] Changes to replace ExEntryPanel with interface and move more code to engine --- src/main/java/com/maddyhome/idea/vim/VimPlugin.java | 8 ++++---- .../com/maddyhome/idea/vim/group/ProcessGroup.kt | 9 ++++----- .../maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt | 7 ++++++- .../idea/vim/action/ex/ProcessExEntryActions.kt | 6 +++--- .../maddyhome/idea/vim/api/VimCommandLineService.kt | 2 ++ .../maddyhome/idea/vim/api/VimProcessGroupBase.kt | 12 +++++++++++- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/VimPlugin.java b/src/main/java/com/maddyhome/idea/vim/VimPlugin.java index a8482a1896..101803c0aa 100644 --- a/src/main/java/com/maddyhome/idea/vim/VimPlugin.java +++ b/src/main/java/com/maddyhome/idea/vim/VimPlugin.java @@ -38,7 +38,6 @@ import com.maddyhome.idea.vim.listener.VimListenerManager; import com.maddyhome.idea.vim.newapi.IjVimInjector; import com.maddyhome.idea.vim.ui.StatusBarIconFactory; -import com.maddyhome.idea.vim.ui.ex.ExEntryPanel; import com.maddyhome.idea.vim.vimscript.services.VariableService; import com.maddyhome.idea.vim.yank.YankGroupBase; import org.jdom.Element; @@ -46,6 +45,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static com.maddyhome.idea.vim.api.VimInjectorKt.injector; import static com.maddyhome.idea.vim.group.EditorGroup.EDITOR_STORE_ELEMENT; import static com.maddyhome.idea.vim.group.KeyGroup.SHORTCUT_CONFLICTS_ELEMENT; import static com.maddyhome.idea.vim.vimscript.services.VimRcService.executeIdeaVimRc; @@ -283,11 +283,11 @@ private void registerIdeavimrc(VimEditor editor) { if (!ApplicationManager.getApplication().isUnitTestMode()) { try { - VimInjectorKt.injector.getOptionGroup().startInitVimRc(); + injector.getOptionGroup().startInitVimRc(); executeIdeaVimRc(editor); } finally { - VimInjectorKt.injector.getOptionGroup().endInitVimRc(); + injector.getOptionGroup().endInitVimRc(); } } } @@ -352,7 +352,7 @@ private void turnOffPlugin(boolean unsubscribe) { if (unsubscribe) { VimListenerManager.INSTANCE.turnOff(); } - ExEntryPanel.fullReset(); + injector.getCommandLine().fullReset(); // Unregister vim actions in command mode RegisterActions.unregisterActions(); diff --git a/src/main/java/com/maddyhome/idea/vim/group/ProcessGroup.kt b/src/main/java/com/maddyhome/idea/vim/group/ProcessGroup.kt index 54f1ac0207..f248195407 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/ProcessGroup.kt +++ b/src/main/java/com/maddyhome/idea/vim/group/ProcessGroup.kt @@ -21,16 +21,15 @@ import com.intellij.util.text.CharSequenceReader import com.maddyhome.idea.vim.KeyHandler.Companion.getInstance import com.maddyhome.idea.vim.KeyProcessResult import com.maddyhome.idea.vim.VimPlugin -import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimProcessGroupBase import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.helper.requestFocus -import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.state.mode.Mode +import com.maddyhome.idea.vim.state.mode.Mode.NORMAL import com.maddyhome.idea.vim.state.mode.ReturnableFromCmd import com.maddyhome.idea.vim.state.mode.inVisualMode import com.maddyhome.idea.vim.state.mode.returnTo @@ -89,10 +88,10 @@ public class ProcessGroup : VimProcessGroupBase() { // This will only get called if somehow the key focus ended up in the editor while the ex entry window // is open. So I'll put focus back in the editor and process the key. - val panel = ExEntryPanel.getInstance() - if (panel.isActive) { + val panel = injector.commandLine.getActiveCommandLine() + if (panel != null) { processResultBuilder.addExecutionStep { _, _, _ -> - requestFocus(panel.entry) + requestFocus((panel as ExEntryPanel).entry) panel.handleKey(stroke) } return true diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt index 26d94a28d8..6abfb4c5d9 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt @@ -25,7 +25,8 @@ import javax.swing.KeyStroke public class ExEntryPanelService : VimCommandLineService { public override fun getActiveCommandLine(): VimCommandLine? { - return ExEntryPanel.instance + val instance = ExEntryPanel.instance ?: return null + return if (instance.isActive) instance else null } override fun inputString(vimEditor: VimEditor, context: ExecutionContext, prompt: String, finishOn: Char?): String? { @@ -93,4 +94,8 @@ public class ExEntryPanelService : VimCommandLineService { panel.activate(editor.ij, context.ij, label, initText, count) return panel } + + override fun fullReset() { + ExEntryPanel.fullReset() + } } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt index 2593ce32b1..04efb98602 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ProcessExEntryActions.kt @@ -60,8 +60,8 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution() override val motionType: MotionType = MotionType.LINE_WISE override fun getOffset(editor: VimEditor, context: ExecutionContext, argument: Argument?, operatorArguments: OperatorArguments): Motion { - val panel = injector.commandLine.getActiveCommandLine()!! - panel.deactivate(true) + if (argument == null) return Motion.Error + try { // Exit Command-line mode and return to the previous mode before executing the command (this is set to Normal in // startExEntry). Remember from startExEntry that we might still have selection and/or multiple carets, even @@ -71,7 +71,7 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution() logger.debug("processing command") - val text = panel.text + val text = argument.string val shouldSkipHistory = getInstance(editor).mappingState.isExecutingMap() || injector.macro.isExecutingMacro injector.vimscriptExecutor.execute(text, editor, context, shouldSkipHistory, true, CommandLineVimLContext) } catch (e: ExException) { diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt index 0b1509d3b9..ae84a8e7f3 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt @@ -23,4 +23,6 @@ public interface VimCommandLineService { * @param count TODO */ public fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine + + public fun fullReset() } \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt index 39438a25e4..d72eec6a0c 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt @@ -8,4 +8,14 @@ package com.maddyhome.idea.vim.api -public abstract class VimProcessGroupBase : VimProcessGroup +import com.maddyhome.idea.vim.KeyHandler.Companion.getInstance +import com.maddyhome.idea.vim.state.mode.Mode.NORMAL + +public abstract class VimProcessGroupBase : VimProcessGroup { + public override fun cancelExEntry(editor: VimEditor, resetCaret: Boolean) { + editor.mode = NORMAL() + injector.commandLine.getActiveCommandLine()?.deactivate(true, resetCaret) + getInstance().keyHandlerState.leaveCommandLine() + getInstance().reset(editor) + } +} From 3379596b32d6318d01d4e83b5322c6bccd0b6c85 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Wed, 29 May 2024 18:24:52 +0300 Subject: [PATCH 02/22] Changes to replace ExEntryPanel with interface and move more code to engine --- .../com/maddyhome/idea/vim/group/SearchGroup.java | 10 +++++++--- .../maddyhome/idea/vim/newapi/IjVimSearchGroup.kt | 8 +++----- .../com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java | 2 +- .../idea/vim/ui/ex/ExEntryPanelService.kt | 14 +++++++++++++- .../idea/vim/api/VimCommandLineService.kt | 2 ++ 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java index a5f5303c2d..bd5f691743 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java +++ b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java @@ -38,7 +38,6 @@ import com.maddyhome.idea.vim.regexp.CharacterClasses; import com.maddyhome.idea.vim.regexp.RegExp; import com.maddyhome.idea.vim.ui.ModalEntry; -import com.maddyhome.idea.vim.ui.ex.ExEntryPanel; import com.maddyhome.idea.vim.vimscript.model.VimLContext; import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString; import com.maddyhome.idea.vim.vimscript.model.expressions.Expression; @@ -1035,8 +1034,13 @@ public Pair> search_regcomp(CharPointer } else { // XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for this method - final ExEntryPanel exEntryPanel = ExEntryPanel.getInstanceWithoutShortcuts(); - exEntryPanel.activate(editor, ((IjEditorExecutionContext)context).getContext(), MessageHelper.message("replace.with.0", match), "", 1); + final VimCommandLine exEntryPanel = injector.getCommandLine().createWithoutShortcuts( + new IjVimEditor(editor), + context, + MessageHelper.message("replace.with.0", match), + "", + 1 + ); new IjVimCaret(caret).moveToOffset(startoff); ModalEntry.INSTANCE.activate(new IjVimEditor(editor), keyStrokeProcessor); exEntryPanel.deactivate(true, false); diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt index c2f4cf7999..043b70ae67 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt @@ -117,11 +117,9 @@ public open class IjVimSearchGroup : VimSearchGroupBase() { } } else { // XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for this method - val exEntryPanel: com.maddyhome.idea.vim.ui.ex.ExEntryPanel = - com.maddyhome.idea.vim.ui.ex.ExEntryPanel.getInstanceWithoutShortcuts() - exEntryPanel.activate( - editor.ij, - (context as IjEditorExecutionContext).context, + val exEntryPanel = injector.commandLine.createWithoutShortcuts( + editor, + context, MessageHelper.message("replace.with.0", match), "", 1 diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 818bd9ae83..ecf1957c94 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -58,7 +58,7 @@ */ public class ExEntryPanel extends JPanel implements VimCommandLine { public static ExEntryPanel instance; - private static ExEntryPanel instanceWithoutShortcuts; + public static ExEntryPanel instanceWithoutShortcuts; private ExEntryPanel(boolean enableShortcuts) { label = new JLabel(" "); diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt index 6abfb4c5d9..909322dac0 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt @@ -25,7 +25,7 @@ import javax.swing.KeyStroke public class ExEntryPanelService : VimCommandLineService { public override fun getActiveCommandLine(): VimCommandLine? { - val instance = ExEntryPanel.instance ?: return null + val instance = ExEntryPanel.instance ?: ExEntryPanel.instanceWithoutShortcuts ?: return null return if (instance.isActive) instance else null } @@ -95,6 +95,18 @@ public class ExEntryPanelService : VimCommandLineService { return panel } + public override fun createWithoutShortcuts( + editor: VimEditor, + context: ExecutionContext, + label: String, + initText: String, + count: Int + ): VimCommandLine { + val panel = ExEntryPanel.getInstanceWithoutShortcuts() + panel.activate(editor.ij, context.ij, label, initText, count) + return panel + } + override fun fullReset() { ExEntryPanel.fullReset() } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt index ae84a8e7f3..d868dcc8d6 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt @@ -24,5 +24,7 @@ public interface VimCommandLineService { */ public fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine + public fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine + public fun fullReset() } \ No newline at end of file From 9681cf9a9e9eef76255f00f487bd703c4f8e0a98 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Wed, 29 May 2024 19:41:34 +0300 Subject: [PATCH 03/22] Changes to replace ExEntryPanel with interface and move more code to engine --- .../idea/vim/listener/VimListenerManager.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt b/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt index 0872c0e480..774aa5a2b2 100644 --- a/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt +++ b/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt @@ -98,7 +98,6 @@ import com.maddyhome.idea.vim.state.mode.inSelectMode import com.maddyhome.idea.vim.state.mode.selectionType import com.maddyhome.idea.vim.ui.ShowCmdOptionChangeListener import com.maddyhome.idea.vim.ui.ShowCmdWidgetUpdater -import com.maddyhome.idea.vim.ui.ex.ExEntryPanel import com.maddyhome.idea.vim.ui.widgets.macro.MacroWidgetListener import com.maddyhome.idea.vim.ui.widgets.macro.macroWidgetOptionListener import com.maddyhome.idea.vim.ui.widgets.mode.listeners.ModeWidgetListener @@ -708,10 +707,10 @@ internal object VimListenerManager { logger.debug("Mouse clicked") if (event.area == EditorMouseEventArea.EDITING_AREA) { - VimPlugin.getMotion() val editor = event.editor - if (ExEntryPanel.getInstance().isActive) { - VimPlugin.getProcess().cancelExEntry(editor.vim, false) + val commandLine = injector.commandLine.getActiveCommandLine() + if (commandLine != null) { + injector.processGroup.cancelExEntry(editor.vim, false) } ExOutputModel.getInstance(editor).clear() @@ -740,9 +739,9 @@ internal object VimListenerManager { event.area != EditorMouseEventArea.FOLDING_OUTLINE_AREA && event.mouseEvent.button != MouseEvent.BUTTON3 ) { - VimPlugin.getMotion() - if (ExEntryPanel.getInstance().isActive) { - VimPlugin.getProcess().cancelExEntry(event.editor.vim, false) + val commandLine = injector.commandLine.getActiveCommandLine() + if (commandLine != null) { + injector.processGroup.cancelExEntry(event.editor.vim, false) } ExOutputModel.getInstance(event.editor).clear() From 73dfc48acb1b885d869e3651cd9467bf996bcf54 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Wed, 29 May 2024 20:39:13 +0300 Subject: [PATCH 04/22] Deprecate ExEntryPanel --- .../com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt | 8 -------- .../com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java | 5 +++++ .../com/maddyhome/idea/vim/ui/ex/ExTextField.java | 5 ----- .../main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt | 6 ++---- .../kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt | 3 +-- .../com/maddyhome/idea/vim/api/VimCommandLine.kt | 2 ++ .../idea/vim/key/consumers/DigraphConsumer.kt | 11 ++++++----- 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt index 7d8721f2fc..25bc3db4dc 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt @@ -13,15 +13,7 @@ import com.maddyhome.idea.vim.api.ExEntryPanel @Service internal class IjExEntryPanel : ExEntryPanel { - override fun isActive(): Boolean { - return com.maddyhome.idea.vim.ui.ex.ExEntryPanel.getInstance().isActive - } - override fun clearCurrentAction() { com.maddyhome.idea.vim.ui.ex.ExEntryPanel.getInstance().entry.clearCurrentAction() } - - override fun setCurrentActionPromptCharacter(char: Char) { - com.maddyhome.idea.vim.ui.ex.ExEntryPanel.getInstance().entry.setCurrentActionPromptCharacter(char) - } } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index ecf1957c94..66b17da791 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -499,6 +499,11 @@ public VimCommandLineCaret getCaret() { return (VimCommandLineCaret) entry.getCaret(); } + @Override + public void setCurrentActionPromptCharacter(char c) { + entry.setCurrentActionPromptCharacter(c); + } + public static class LafListener implements LafManagerListener { @Override public void lookAndFeelChanged(@NotNull LafManager source) { diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java index b54468239e..57d18ca1c0 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java @@ -306,11 +306,6 @@ void cancel() { } } - public void setCurrentAction(@NotNull MultiStepAction action, char pendingIndicator) { - this.currentAction = action; - setCurrentActionPromptCharacter(pendingIndicator); - } - public void clearCurrentAction() { if (currentAction != null) { currentAction.reset(); diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt index 1813442675..3cbd5d0535 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt @@ -294,10 +294,8 @@ public class KeyHandler { } public fun setPromptCharacterEx(promptCharacter: Char) { - val exEntryPanel = injector.exEntryPanel - if (exEntryPanel.isActive()) { - exEntryPanel.setCurrentActionPromptCharacter(promptCharacter) - } + val commandLine = injector.commandLine.getActiveCommandLine() ?: return + commandLine.setCurrentActionPromptCharacter(promptCharacter) } /** diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt index 74d2954d57..6bf076ce81 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt @@ -9,7 +9,6 @@ package com.maddyhome.idea.vim.api public interface ExEntryPanel { - public fun isActive(): Boolean + @Deprecated("Remove it after completely removing Swing TextActions") public fun clearCurrentAction() - public fun setCurrentActionPromptCharacter(char: Char) } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index 865a7a26e6..dec0901c93 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -17,4 +17,6 @@ public interface VimCommandLine { public fun handleKey(key: KeyStroke) public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean = true) + + public fun setCurrentActionPromptCharacter(char: Char) } \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt index 8aa559df67..fc5f561e35 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt @@ -59,15 +59,15 @@ public class DigraphConsumer : KeyConsumer { when (res.result) { DigraphResult.RES_HANDLED -> { keyProcessResultBuilder.addExecutionStep { lambdaKeyState, _, _ -> - if (injector.exEntryPanel.isActive()) { - keyHandler.setPromptCharacterEx(if (lambdaKeyState.commandBuilder.isPuttingLiteral()) '^' else key.keyChar) - } + val commandLine = injector.commandLine.getActiveCommandLine() + commandLine?.setCurrentActionPromptCharacter(if (lambdaKeyState.commandBuilder.isPuttingLiteral()) '^' else key.keyChar) lambdaKeyState.commandBuilder.addKey(key) } return true } DigraphResult.RES_DONE -> { - if (injector.exEntryPanel.isActive()) { + val commandLine = injector.commandLine.getActiveCommandLine() + if (commandLine != null) { if (key.keyCode == KeyEvent.VK_C && key.modifiers and InputEvent.CTRL_DOWN_MASK != 0) { return false } else { @@ -90,7 +90,8 @@ public class DigraphConsumer : KeyConsumer { return true } DigraphResult.RES_BAD -> { - if (injector.exEntryPanel.isActive()) { + val commandLine = injector.commandLine.getActiveCommandLine() + if (commandLine != null) { if (key.keyCode == KeyEvent.VK_C && key.modifiers and InputEvent.CTRL_DOWN_MASK != 0) { return false } else { From 58ea226933ed7dba648e7da5cf24d05529183d2a Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Thu, 30 May 2024 15:12:00 +0300 Subject: [PATCH 05/22] Remove count for command line It was not used anywhere --- .../maddyhome/idea/vim/group/SearchGroup.java | 3 +-- .../idea/vim/newapi/IjVimSearchGroup.kt | 1 - .../maddyhome/idea/vim/ui/ex/ExEntryPanel.java | 14 +------------- .../idea/vim/ui/ex/ExEntryPanelService.kt | 16 +++++----------- .../idea/vim/action/ex/ExEntryAction.kt | 2 ++ .../action/motion/search/SearchEntryActions.kt | 5 ++--- .../idea/vim/api/VimCommandLineService.kt | 5 ++--- 7 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java index bd5f691743..454c41037f 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java +++ b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java @@ -1038,8 +1038,7 @@ public Pair> search_regcomp(CharPointer new IjVimEditor(editor), context, MessageHelper.message("replace.with.0", match), - "", - 1 + "" ); new IjVimCaret(caret).moveToOffset(startoff); ModalEntry.INSTANCE.activate(new IjVimEditor(editor), keyStrokeProcessor); diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt index 043b70ae67..b3fad7ab7e 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt @@ -122,7 +122,6 @@ public open class IjVimSearchGroup : VimSearchGroupBase() { context, MessageHelper.message("replace.with.0", match), "", - 1 ) caret.moveToOffset(startOffset) ModalEntry.activate(editor, keyStrokeProcessor) diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 66b17da791..92bc936152 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -132,13 +132,11 @@ public static void fullReset() { * @param context The data context * @param label The label for the ex entry (i.e. :, /, or ?) * @param initText The initial text for the entry - * @param count A holder for the ex entry count */ - public void activate(@NotNull Editor editor, DataContext context, @NotNull String label, String initText, int count) { + public void activate(@NotNull Editor editor, DataContext context, @NotNull String label, String initText) { logger.info("Activate ex entry panel"); this.label.setText(label); this.label.setFont(UiHelper.selectFont(label)); - this.count = count; entry.reset(); entry.setEditor(editor, context); entry.setText(initText); @@ -365,15 +363,6 @@ public String getLabel() { return label.getText(); } - /** - * Gets the count given during activation - * - * @return The count - */ - public int getCount() { - return count; - } - /** * Checks if the ex entry panel is currently active * @@ -469,7 +458,6 @@ private boolean isIncSearchEnabled() { } private boolean active; - private int count; // UI stuff private @Nullable JComponent parent; diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt index 909322dac0..274bffdddb 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt @@ -58,7 +58,7 @@ public class ExEntryPanelService : VimCommandLineService { } else { var text: String? = null // XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for input() - val commandLine = injector.commandLine.create(vimEditor, context, prompt.ifEmpty { " " }, "", 1) + val commandLine = injector.commandLine.create(vimEditor, context, prompt.ifEmpty { " " }, "") ModalEntry.activate(editor.vim) { key: KeyStroke -> return@activate when { key.isCloseKeyStroke() -> { @@ -89,21 +89,15 @@ public class ExEntryPanelService : VimCommandLineService { } } - public override fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine { + public override fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine { val panel = ExEntryPanel.getInstance() - panel.activate(editor.ij, context.ij, label, initText, count) + panel.activate(editor.ij, context.ij, label, initText) return panel } - public override fun createWithoutShortcuts( - editor: VimEditor, - context: ExecutionContext, - label: String, - initText: String, - count: Int - ): VimCommandLine { + public override fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine { val panel = ExEntryPanel.getInstanceWithoutShortcuts() - panel.activate(editor.ij, context.ij, label, initText, count) + panel.activate(editor.ij, context.ij, label, initText) return panel } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ExEntryAction.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ExEntryAction.kt index e49f33a442..1e65c0819c 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ExEntryAction.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/ExEntryAction.kt @@ -17,6 +17,8 @@ import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.handler.VimActionHandler import com.maddyhome.idea.vim.helper.enumSetOf +import com.maddyhome.idea.vim.helper.vimStateMachine +import com.maddyhome.idea.vim.state.mode.ReturnableFromCmd import java.util.* @CommandOrMotion(keys = [":"], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING]) diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/motion/search/SearchEntryActions.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/motion/search/SearchEntryActions.kt index d539679291..ebd0fb720b 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/motion/search/SearchEntryActions.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/motion/search/SearchEntryActions.kt @@ -12,7 +12,6 @@ import com.intellij.vim.annotations.Mode import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.injector -import com.maddyhome.idea.vim.command.Argument import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.command.CommandFlags import com.maddyhome.idea.vim.command.OperatorArguments @@ -27,7 +26,7 @@ public class SearchEntryFwdAction : VimActionHandler.SingleExecution() { override val flags: EnumSet = enumSetOf(CommandFlags.FLAG_START_EX, CommandFlags.FLAG_SAVE_JUMP) override fun execute( editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { - startSearchCommand('/', editor, context, cmd) + startSearchCommand('/', editor, context) return true } } @@ -38,7 +37,7 @@ public class SearchEntryRevAction : VimActionHandler.SingleExecution() { override val flags: EnumSet = enumSetOf(CommandFlags.FLAG_START_EX, CommandFlags.FLAG_SAVE_JUMP) override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { - startSearchCommand('?', editor, context, cmd) + startSearchCommand('?', editor, context) return true } } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt index d868dcc8d6..180d344bf6 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLineService.kt @@ -20,11 +20,10 @@ public interface VimCommandLineService { * @param context The data context * @param label The label for the command line (i.e. :, /, or ?) * @param initText The initial text for the entry - * @param count TODO */ - public fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine + public fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine - public fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine + public fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine public fun fullReset() } \ No newline at end of file From 3a515a89dd5831faf3e16ca736e3665a106c3ba4 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Fri, 31 May 2024 21:29:20 +0300 Subject: [PATCH 06/22] Remove default value --- .../java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt | 2 +- .../com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt | 6 +++--- .../kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt | 2 +- .../com/maddyhome/idea/vim/api/VimProcessGroupBase.kt | 2 +- .../com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt index b3fad7ab7e..f39d88bdc4 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimSearchGroup.kt @@ -125,7 +125,7 @@ public open class IjVimSearchGroup : VimSearchGroupBase() { ) caret.moveToOffset(startOffset) ModalEntry.activate(editor, keyStrokeProcessor) - exEntryPanel.deactivate(true, false) + exEntryPanel.deactivate(refocusOwningEditor = true, resetCaret = false) } return result.get() } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt index 274bffdddb..6b1c30ade8 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt @@ -62,18 +62,18 @@ public class ExEntryPanelService : VimCommandLineService { ModalEntry.activate(editor.vim) { key: KeyStroke -> return@activate when { key.isCloseKeyStroke() -> { - commandLine.deactivate(true) + commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) false } key.keyCode == KeyEvent.VK_ENTER -> { text = commandLine.text - commandLine.deactivate(true) + commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) false } finishOn != null && key.keyChar == finishOn -> { commandLine.handleKey(key) text = commandLine.text - commandLine.deactivate(true) + commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) false } else -> { diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index dec0901c93..1419f754db 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -16,7 +16,7 @@ public interface VimCommandLine { public val caret: VimCommandLineCaret public fun handleKey(key: KeyStroke) - public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean = true) + public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) public fun setCurrentActionPromptCharacter(char: Char) } \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt index d72eec6a0c..1f9917ae14 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimProcessGroupBase.kt @@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.state.mode.Mode.NORMAL public abstract class VimProcessGroupBase : VimProcessGroup { public override fun cancelExEntry(editor: VimEditor, resetCaret: Boolean) { editor.mode = NORMAL() - injector.commandLine.getActiveCommandLine()?.deactivate(true, resetCaret) + injector.commandLine.getActiveCommandLine()?.deactivate(refocusOwningEditor = true, resetCaret) getInstance().keyHandlerState.leaveCommandLine() getInstance().reset(editor) } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt index 4ba99da22c..10db462ee8 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt @@ -131,7 +131,7 @@ public class CommandConsumer : KeyConsumer { val commandLine = injector.commandLine.getActiveCommandLine()!! val label = commandLine.label val text = commandLine.text - commandLine.deactivate(true) + commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) commandBuilder.completeCommandPart(Argument(label[0], text)) lambdaEditor.mode = lambdaEditor.mode.returnTo() From 27cd0f8bec93e976f86b36ab9a59b33ff0a7d14c Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Fri, 31 May 2024 21:54:12 +0300 Subject: [PATCH 07/22] Introduce `actualText` and `visibleText` for command line --- .../idea/vim/ui/ex/ExEntryPanel.java | 20 +++++++++---------- .../idea/vim/ui/ex/ExEntryPanelService.kt | 4 ++-- .../maddyhome/idea/vim/ui/ex/ExTextField.java | 2 +- .../plugins/ideavim/ex/ExEntryTest.kt | 2 +- .../vim/action/ex/InsertRegisterAction.kt | 2 +- .../maddyhome/idea/vim/api/VimCommandLine.kt | 15 +++++++++++++- .../idea/vim/key/consumers/CommandConsumer.kt | 2 +- 7 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 92bc936152..c1fd6ba89c 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -255,7 +255,7 @@ private void resetCaretOffset(@NotNull Editor editor) { private final @NotNull DocumentListener fontListener = new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { - String text = entry.getActualText(); + String text = entry.getText(); Font newFont = UiHelper.selectFont(text); if (newFont != entry.getFont()) { entry.setFont(newFont); @@ -372,19 +372,14 @@ public boolean isActive() { return active; } - /** - * Gets the text entered by the user. This includes any initial text but does not include the label - * - * @return The user entered text - */ @Override - public @NotNull String getText() { - return entry.getActualText(); + public @NotNull String getVisibleText() { + return entry.getText(); } @Override - public void setText(@NotNull String s) { - entry.setText(s); + public @NotNull String getActualText() { + return entry.getText(); } public @NotNull ExTextField getEntry() { @@ -492,6 +487,11 @@ public void setCurrentActionPromptCharacter(char c) { entry.setCurrentActionPromptCharacter(c); } + @Override + public void setText(@NotNull String string) { + entry.updateText(string); + } + public static class LafListener implements LafManagerListener { @Override public void lookAndFeelChanged(@NotNull LafManager source) { diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt index 6b1c30ade8..b0c55c769b 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanelService.kt @@ -66,13 +66,13 @@ public class ExEntryPanelService : VimCommandLineService { false } key.keyCode == KeyEvent.VK_ENTER -> { - text = commandLine.text + text = commandLine.actualText commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) false } finishOn != null && key.keyChar == finishOn -> { commandLine.handleKey(key) - text = commandLine.text + text = commandLine.actualText commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) false } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java index 57d18ca1c0..a795d27740 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java @@ -187,7 +187,7 @@ void selectHistory(boolean isUp, boolean filter) { } } - private void updateText(String string) { + void updateText(String string) { super.setText(string); setFontToJField(string); } diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/ExEntryTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/ExEntryTest.kt index 890a39c838..81a54cf8a0 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/ExEntryTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/ExEntryTest.kt @@ -518,7 +518,7 @@ class ExEntryTest : VimTestCase() { // this isn't true - digraph entry is stopped, but command line mode continues typeExInput(":OK") assertIsActive() - assertEquals("K", exEntryPanel.text) + assertEquals("K", exEntryPanel.actualText) deactivateExEntry() } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt index 3e300af639..9cf50883ca 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt @@ -36,7 +36,7 @@ public class InsertRegisterAction: VimActionHandler.SingleExecution() { } else { throw ExException("Not yet implemented") } ?: return false - cmdLine.text = StringBuilder(cmdLine.text).insert(caretOffset, pasteContent).toString() + cmdLine.setText(StringBuilder(cmdLine.actualText).insert(caretOffset, pasteContent).toString()) cmdLine.caret.offset = caretOffset + pasteContent.length return true } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index 1419f754db..bb1ab6d899 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -12,9 +12,22 @@ import javax.swing.KeyStroke public interface VimCommandLine { public val label: String - public var text: String + + /** + * The actual text present in the command line, excluding special characters like the `?` displayed during digraph input. + * This text represents the real content that is being processed or executed. + */ + public val actualText: String + + /** + * The text content displayed in the command line, including any additional characters or symbols + * that might be shown to the user, such as the `?` during digraph input. + * This is the text that the user sees on the screen. + */ + public val visibleText: String public val caret: VimCommandLineCaret + public fun setText(string: String) public fun handleKey(key: KeyStroke) public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt index 10db462ee8..4aa71d377c 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/CommandConsumer.kt @@ -130,7 +130,7 @@ public class CommandConsumer : KeyConsumer { logger.trace("Processing ex_string") val commandLine = injector.commandLine.getActiveCommandLine()!! val label = commandLine.label - val text = commandLine.text + val text = commandLine.actualText commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) commandBuilder.completeCommandPart(Argument(label[0], text)) From 886d4111e9f548e96f71453d3519a4c630bec125 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Fri, 31 May 2024 22:20:19 +0300 Subject: [PATCH 08/22] Rename method --- src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java | 2 +- .../src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt | 2 +- .../main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt | 5 +++-- .../com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index c1fd6ba89c..c0b468ed9d 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -483,7 +483,7 @@ public VimCommandLineCaret getCaret() { } @Override - public void setCurrentActionPromptCharacter(char c) { + public void setPromptCharacter(char c) { entry.setCurrentActionPromptCharacter(c); } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt index 3cbd5d0535..ee914b653b 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/KeyHandler.kt @@ -295,7 +295,7 @@ public class KeyHandler { public fun setPromptCharacterEx(promptCharacter: Char) { val commandLine = injector.commandLine.getActiveCommandLine() ?: return - commandLine.setCurrentActionPromptCharacter(promptCharacter) + commandLine.setPromptCharacter(promptCharacter) } /** diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index bb1ab6d899..cf5f4bc98a 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -11,6 +11,8 @@ package com.maddyhome.idea.vim.api import javax.swing.KeyStroke public interface VimCommandLine { + public val caret: VimCommandLineCaret + public val label: String /** @@ -25,11 +27,10 @@ public interface VimCommandLine { * This is the text that the user sees on the screen. */ public val visibleText: String - public val caret: VimCommandLineCaret public fun setText(string: String) public fun handleKey(key: KeyStroke) public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) - public fun setCurrentActionPromptCharacter(char: Char) + public fun setPromptCharacter(char: Char) } \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt index fc5f561e35..715219fefe 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt @@ -60,7 +60,7 @@ public class DigraphConsumer : KeyConsumer { DigraphResult.RES_HANDLED -> { keyProcessResultBuilder.addExecutionStep { lambdaKeyState, _, _ -> val commandLine = injector.commandLine.getActiveCommandLine() - commandLine?.setCurrentActionPromptCharacter(if (lambdaKeyState.commandBuilder.isPuttingLiteral()) '^' else key.keyChar) + commandLine?.setPromptCharacter(if (lambdaKeyState.commandBuilder.isPuttingLiteral()) '^' else key.keyChar) lambdaKeyState.commandBuilder.addKey(key) } return true From a20f3f973c27c230f230e4929d17d9d4e6f0aeb9 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Fri, 31 May 2024 22:27:41 +0300 Subject: [PATCH 09/22] Remove ExEntryPanel and move its method to VimCommandLine --- .../idea/vim/newapi/IjExEntryPanel.kt | 19 ------------------- .../idea/vim/newapi/IjVimInjector.kt | 3 --- .../idea/vim/ui/ex/ExEntryPanel.java | 10 ++++++++++ .../maddyhome/idea/vim/ui/ex/ExTextField.java | 2 +- .../maddyhome/idea/vim/api/ExEntryPanel.kt | 14 -------------- .../maddyhome/idea/vim/api/VimCommandLine.kt | 3 +++ .../com/maddyhome/idea/vim/api/VimInjector.kt | 3 --- .../idea/vim/key/consumers/DigraphConsumer.kt | 4 ++-- 8 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt delete mode 100644 vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt deleted file mode 100644 index 25bc3db4dc..0000000000 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjExEntryPanel.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2003-2023 The IdeaVim authors - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE.txt file or at - * https://opensource.org/licenses/MIT. - */ - -package com.maddyhome.idea.vim.newapi - -import com.intellij.openapi.components.Service -import com.maddyhome.idea.vim.api.ExEntryPanel - -@Service -internal class IjExEntryPanel : ExEntryPanel { - override fun clearCurrentAction() { - com.maddyhome.idea.vim.ui.ex.ExEntryPanel.getInstance().entry.clearCurrentAction() - } -} diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimInjector.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimInjector.kt index a240ea8953..2471e1c478 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimInjector.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimInjector.kt @@ -14,7 +14,6 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.textarea.TextComponentEditorImpl import com.maddyhome.idea.vim.api.EngineEditorHelper -import com.maddyhome.idea.vim.api.ExEntryPanel import com.maddyhome.idea.vim.api.ExecutionContextManager import com.maddyhome.idea.vim.api.LocalOptionInitialisationScenario import com.maddyhome.idea.vim.api.NativeActionManager @@ -107,8 +106,6 @@ internal class IjVimInjector : VimInjectorBase() { override val actionExecutor: VimActionExecutor get() = service() - override val exEntryPanel: ExEntryPanel - get() = service() override val exOutputPanel: VimExOutputPanelService get() = object : VimExOutputPanelService { override fun getPanel(editor: VimEditor): VimExOutputPanel { diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index c0b468ed9d..705ed28698 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -492,6 +492,16 @@ public void setText(@NotNull String string) { entry.updateText(string); } + @Override + public void clearPromptCharacter() { + entry.clearCurrentActionPromptCharacter(); + } + + @Override + public void clearCurrentAction() { + entry.clearCurrentAction(); + } + public static class LafListener implements LafManagerListener { @Override public void lookAndFeelChanged(@NotNull LafManager source) { diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java index a795d27740..0d42d05c06 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java @@ -333,7 +333,7 @@ public void setCurrentActionPromptCharacter(char promptCharacter) { setCaretPosition(currentActionPromptCharacterOffset); } - private void clearCurrentActionPromptCharacter() { + void clearCurrentActionPromptCharacter() { final int offset = getCaretPosition(); final String text = removePromptCharacter(); updateText(text); diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt deleted file mode 100644 index 6bf076ce81..0000000000 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/ExEntryPanel.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2003-2023 The IdeaVim authors - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE.txt file or at - * https://opensource.org/licenses/MIT. - */ - -package com.maddyhome.idea.vim.api - -public interface ExEntryPanel { - @Deprecated("Remove it after completely removing Swing TextActions") - public fun clearCurrentAction() -} diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index cf5f4bc98a..6fed61d722 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -33,4 +33,7 @@ public interface VimCommandLine { public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) public fun setPromptCharacter(char: Char) + public fun clearPromptCharacter() + + public fun clearCurrentAction() } \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimInjector.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimInjector.kt index aef07498e0..c5959361a8 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimInjector.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimInjector.kt @@ -108,9 +108,6 @@ public interface VimInjector { // Can't be fully moved to vim-engine. public val actionExecutor: VimActionExecutor - // Can't be fully moved to vim-engine. - public val exEntryPanel: ExEntryPanel - // Can't be fully moved to vim-engine. public val exOutputPanel: VimExOutputPanelService diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt index 715219fefe..43bdf0c056 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/consumers/DigraphConsumer.kt @@ -72,7 +72,7 @@ public class DigraphConsumer : KeyConsumer { return false } else { keyProcessResultBuilder.addExecutionStep { _, _, _ -> - injector.exEntryPanel.clearCurrentAction() + commandLine.clearCurrentAction() } } } @@ -96,7 +96,7 @@ public class DigraphConsumer : KeyConsumer { return false } else { keyProcessResultBuilder.addExecutionStep { _, _, _ -> - injector.exEntryPanel.clearCurrentAction() + commandLine.clearCurrentAction() } } } From 7ef1498a25bcc082b4a7e30a4202770a7f702bf4 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Sat, 1 Jun 2024 00:17:57 +0300 Subject: [PATCH 10/22] Move more logic to VimCommandLine interface --- .../idea/vim/ui/ex/ExEntryPanel.java | 33 ++++++------ .../maddyhome/idea/vim/ui/ex/ExTextField.java | 53 ++----------------- .../maddyhome/idea/vim/api/VimCommandLine.kt | 37 +++++++++++-- 3 files changed, 57 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 705ed28698..2d34c3a2e7 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -189,7 +189,6 @@ public void deactivate(boolean refocusOwningEditor) { public void deactivate(boolean refocusOwningEditor, boolean resetCaret) { logger.info("Deactivate ex entry panel"); if (!active) return; - active = false; try { entry.getDocument().removeDocumentListener(fontListener); @@ -232,6 +231,9 @@ public void deactivate(boolean refocusOwningEditor, boolean resetCaret) { parent = null; } + + // We have this in the end, because `entry.deactivate()` communicates with active panel during deactivation + active = false; } private void reset() { @@ -377,11 +379,6 @@ public boolean isActive() { return entry.getText(); } - @Override - public @NotNull String getActualText() { - return entry.getText(); - } - public @NotNull ExTextField getEntry() { return entry; } @@ -429,7 +426,7 @@ public Color getBackground() { private void setFontForElements() { label.setFont(UiHelper.selectFont(label.getText())); - entry.setFont(UiHelper.selectFont(entry.getActualText())); + entry.setFont(UiHelper.selectFont(getVisibleText())); } private void positionPanel() { @@ -483,25 +480,31 @@ public VimCommandLineCaret getCaret() { } @Override - public void setPromptCharacter(char c) { - entry.setCurrentActionPromptCharacter(c); + public void setText(@NotNull String string) { + // It's a feature of Swing that caret is moved when we set new text. However, our API is Swing independent and we do not expect this + int offset = getCaret().getOffset(); + entry.updateText(string); + getCaret().setOffset(Math.min(offset, getVisibleText().length())); } @Override - public void setText(@NotNull String string) { - entry.updateText(string); + public void clearCurrentAction() { + entry.clearCurrentAction(); } + @Nullable @Override - public void clearPromptCharacter() { - entry.clearCurrentActionPromptCharacter(); + public Integer getPromptCharacterOffset() { + int offset = entry.currentActionPromptCharacterOffset; + return offset == -1 ? null : offset; } @Override - public void clearCurrentAction() { - entry.clearCurrentAction(); + public void setPromptCharacterOffset(@Nullable Integer integer) { + entry.currentActionPromptCharacterOffset = integer == null ? -1 : integer; } + public static class LafListener implements LafManagerListener { @Override public void lookAndFeelChanged(@NotNull LafManager source) { diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java index 0d42d05c06..7dd6022820 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java @@ -14,6 +14,7 @@ import com.intellij.ui.paint.PaintUtil; import com.intellij.util.ui.JBUI; import com.maddyhome.idea.vim.VimPlugin; +import com.maddyhome.idea.vim.api.VimCommandLine; import com.maddyhome.idea.vim.api.VimCommandLineCaret; import com.maddyhome.idea.vim.group.EditorHolderService; import com.maddyhome.idea.vim.helper.UiHelper; @@ -40,6 +41,7 @@ import java.util.Date; import java.util.List; +import static com.maddyhome.idea.vim.api.VimInjectorKt.injector; import static java.lang.Math.*; /** @@ -205,15 +207,6 @@ private void setFontToJField(String stringToDisplay) { super.setFont(UiHelper.selectFont(stringToDisplay)); } - @NotNull - String getActualText() { - if (actualText != null) { - return actualText; - } - final String text = super.getText(); - return text == null ? "" : text; - } - void setEditor(@NotNull Editor editor, DataContext context) { this.context = context; EditorHolderService.getInstance().setEditor(editor); @@ -311,42 +304,8 @@ public void clearCurrentAction() { currentAction.reset(); } currentAction = null; - clearCurrentActionPromptCharacter(); - } - - /** - * Text to show while composing a digraph or inserting a literal or register - *

- * The prompt character is inserted directly into the text of the text field, rather than drawn over the top of the - * current character. When the action has been completed, the new character(s) are either inserted or overwritten, - * depending on the insert/overwrite status of the text field. This mimics Vim's behaviour. - * - * @param promptCharacter The character to show as prompt - */ - public void setCurrentActionPromptCharacter(char promptCharacter) { - actualText = removePromptCharacter(); - this.currentActionPromptCharacter = promptCharacter; - currentActionPromptCharacterOffset = currentActionPromptCharacterOffset == -1 ? getCaretPosition() : currentActionPromptCharacterOffset; - StringBuilder sb = new StringBuilder(actualText); - sb.insert(currentActionPromptCharacterOffset, currentActionPromptCharacter); - updateText(sb.toString()); - setCaretPosition(currentActionPromptCharacterOffset); - } - - void clearCurrentActionPromptCharacter() { - final int offset = getCaretPosition(); - final String text = removePromptCharacter(); - updateText(text); - setCaretPosition(min(offset, text.length())); - currentActionPromptCharacter = '\0'; - currentActionPromptCharacterOffset = -1; - actualText = null; - } - - private String removePromptCharacter() { - return currentActionPromptCharacterOffset == -1 - ? super.getText() - : StringsKt.removeRange(super.getText(), currentActionPromptCharacterOffset, currentActionPromptCharacterOffset + 1).toString(); + VimCommandLine commandLine = injector.getCommandLine().getActiveCommandLine(); + if (commandLine != null) commandLine.clearPromptCharacter(); } @Nullable @@ -574,12 +533,10 @@ public void setOffset(int i) { private DataContext context; private final CommandLineCaret caret; private String lastEntry; - private String actualText; private List history; private int histIndex = 0; private @Nullable MultiStepAction currentAction; - private char currentActionPromptCharacter; - private int currentActionPromptCharacterOffset = -1; + int currentActionPromptCharacterOffset = -1; private static final Logger logger = Logger.getInstance(ExTextField.class.getName()); } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index 6fed61d722..6bff5a7a7b 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -8,7 +8,11 @@ package com.maddyhome.idea.vim.api +import com.maddyhome.idea.vim.KeyHandler +import com.maddyhome.idea.vim.command.MappingMode +import com.maddyhome.idea.vim.impl.state.toMappingMode import javax.swing.KeyStroke +import kotlin.math.min public interface VimCommandLine { public val caret: VimCommandLineCaret @@ -20,6 +24,9 @@ public interface VimCommandLine { * This text represents the real content that is being processed or executed. */ public val actualText: String + get() = if (promptCharacterOffset == null) visibleText else { + visibleText.removeRange(promptCharacterOffset!!, promptCharacterOffset!! + 1) + } /** * The text content displayed in the command line, including any additional characters or symbols @@ -27,13 +34,37 @@ public interface VimCommandLine { * This is the text that the user sees on the screen. */ public val visibleText: String + public var promptCharacterOffset: Int? public fun setText(string: String) public fun handleKey(key: KeyStroke) - public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) - public fun setPromptCharacter(char: Char) - public fun clearPromptCharacter() + /** + * Text to show while composing a digraph or inserting a literal or register + *

+ * The prompt character is inserted directly into the text of the text field, rather than drawn over the top of the + * current character. When the action has been completed, the new character(s) are either inserted or overwritten, + * depending on the insert/overwrite status of the text field. This mimics Vim's behaviour. + * + * @param promptCharacter The character to show as prompt + */ + public fun setPromptCharacter(char: Char) { + val stringBuilder = StringBuilder(actualText) + + val offset = promptCharacterOffset ?: caret.offset // TODO is there a case where caret is not at the [promptCharacterOffset]? + promptCharacterOffset = offset + stringBuilder.insert(offset, char) + setText(stringBuilder.toString()) + + caret.offset = offset + } + public fun clearPromptCharacter() { + setText(actualText) + caret.offset = min(caret.offset, visibleText.length) + promptCharacterOffset = null + } public fun clearCurrentAction() + + public fun deactivate(refocusOwningEditor: Boolean, resetCaret: Boolean) } \ No newline at end of file From 851681aaf145f03513803fef0f9fd5ede4f8ef8a Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Sun, 2 Jun 2024 01:47:47 +0300 Subject: [PATCH 11/22] Support replace mode in command line --- .../com/maddyhome/idea/vim/ui/ex/ExDocument.java | 7 +++++++ .../maddyhome/idea/vim/ui/ex/ExEntryPanel.java | 11 +++++++++++ .../idea/vim/action/ex/InsertRegisterAction.kt | 2 +- .../com/maddyhome/idea/vim/api/VimCommandLine.kt | 16 +++++++++++++--- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExDocument.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExDocument.java index 4606d7c1d4..a1d5dd3326 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExDocument.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExDocument.java @@ -9,6 +9,7 @@ package com.maddyhome.idea.vim.ui.ex; import com.intellij.openapi.util.SystemInfo; +import com.maddyhome.idea.vim.api.VimCommandLine; import org.jetbrains.annotations.NotNull; import javax.swing.text.*; @@ -18,6 +19,8 @@ import java.text.AttributedString; import java.util.Map; +import static com.maddyhome.idea.vim.api.VimInjectorKt.injector; + /** * This document provides insert/overwrite mode * Note that PlainDocument will remove CRs from text for single line text fields @@ -29,6 +32,10 @@ public class ExDocument extends PlainDocument { * Toggles the insert/overwrite state */ void toggleInsertReplace() { + VimCommandLine commandLine = injector.getCommandLine().getActiveCommandLine(); + if (commandLine != null) { + commandLine.toggleReplaceMode(); + } overwrite = !overwrite; } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 2d34c3a2e7..26701a3830 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -59,6 +59,7 @@ public class ExEntryPanel extends JPanel implements VimCommandLine { public static ExEntryPanel instance; public static ExEntryPanel instanceWithoutShortcuts; + private boolean isReplaceMode = false; private ExEntryPanel(boolean enableShortcuts) { label = new JLabel(" "); @@ -212,6 +213,7 @@ public void deactivate(boolean refocusOwningEditor, boolean resetCaret) { VimPlugin.getSearch().resetIncsearchHighlights(); } + isReplaceMode = false; entry.deactivate(); } finally { @@ -365,6 +367,11 @@ public String getLabel() { return label.getText(); } + @Override + public void toggleReplaceMode() { + isReplaceMode = !isReplaceMode; + } + /** * Checks if the ex entry panel is currently active * @@ -504,6 +511,10 @@ public void setPromptCharacterOffset(@Nullable Integer integer) { entry.currentActionPromptCharacterOffset = integer == null ? -1 : integer; } + @Override + public boolean isReplaceMode() { + return isReplaceMode; + } public static class LafListener implements LafManagerListener { @Override diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt index 9cf50883ca..844a1d2978 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/InsertRegisterAction.kt @@ -36,7 +36,7 @@ public class InsertRegisterAction: VimActionHandler.SingleExecution() { } else { throw ExException("Not yet implemented") } ?: return false - cmdLine.setText(StringBuilder(cmdLine.actualText).insert(caretOffset, pasteContent).toString()) + cmdLine.insertText(caretOffset, pasteContent) cmdLine.caret.offset = caretOffset + pasteContent.length return true } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt index 6bff5a7a7b..bc48e36186 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt @@ -8,9 +8,6 @@ package com.maddyhome.idea.vim.api -import com.maddyhome.idea.vim.KeyHandler -import com.maddyhome.idea.vim.command.MappingMode -import com.maddyhome.idea.vim.impl.state.toMappingMode import javax.swing.KeyStroke import kotlin.math.min @@ -18,6 +15,9 @@ public interface VimCommandLine { public val caret: VimCommandLineCaret public val label: String + public val isReplaceMode: Boolean + + public fun toggleReplaceMode() /** * The actual text present in the command line, excluding special characters like the `?` displayed during digraph input. @@ -37,6 +37,16 @@ public interface VimCommandLine { public var promptCharacterOffset: Int? public fun setText(string: String) + public fun insertText(offset: Int, string: String) { + val newText = if (isReplaceMode) { + val endOffset = min(offset + string.length, actualText.length) + StringBuilder(actualText).replace(offset, endOffset, string) + } else { + StringBuilder(actualText).insert(offset, string) + }.toString() + setText(newText) + } + public fun handleKey(key: KeyStroke) /** From b290b4094d2a5f142f21ac10c8717e0edafeda10 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Sun, 2 Jun 2024 02:20:33 +0300 Subject: [PATCH 12/22] Remove EditorHolderService.kt --- .../maddyhome/idea/vim/VimProjectService.kt | 4 ++-- .../idea/vim/action/VimShortcutKeyAction.kt | 4 ++-- .../idea/vim/group/EditorHolderService.kt | 23 ------------------- .../idea/vim/ui/ex/ExEntryPanel.java | 14 +++++++++++ .../maddyhome/idea/vim/ui/ex/ExTextField.java | 10 ++++---- 5 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/maddyhome/idea/vim/group/EditorHolderService.kt diff --git a/src/main/java/com/maddyhome/idea/vim/VimProjectService.kt b/src/main/java/com/maddyhome/idea/vim/VimProjectService.kt index 5a981a5d73..8f744185a0 100644 --- a/src/main/java/com/maddyhome/idea/vim/VimProjectService.kt +++ b/src/main/java/com/maddyhome/idea/vim/VimProjectService.kt @@ -12,13 +12,13 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.project.Project -import com.maddyhome.idea.vim.group.EditorHolderService +import com.maddyhome.idea.vim.ui.ex.ExEntryPanel @Service(Service.Level.PROJECT) internal class VimProjectService(val project: Project) : Disposable { override fun dispose() { // Not sure if this is a best solution - EditorHolderService.getInstance().editor = null + ExEntryPanel.getInstance().editor = null } companion object { diff --git a/src/main/java/com/maddyhome/idea/vim/action/VimShortcutKeyAction.kt b/src/main/java/com/maddyhome/idea/vim/action/VimShortcutKeyAction.kt index e39d33023d..9cb4999004 100644 --- a/src/main/java/com/maddyhome/idea/vim/action/VimShortcutKeyAction.kt +++ b/src/main/java/com/maddyhome/idea/vim/action/VimShortcutKeyAction.kt @@ -26,7 +26,6 @@ import com.maddyhome.idea.vim.KeyHandler import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.injector -import com.maddyhome.idea.vim.group.EditorHolderService import com.maddyhome.idea.vim.group.IjOptionConstants import com.maddyhome.idea.vim.group.IjOptions import com.maddyhome.idea.vim.handler.enableOctopus @@ -45,6 +44,7 @@ import com.maddyhome.idea.vim.listener.AceJumpService import com.maddyhome.idea.vim.listener.AppCodeTemplates.appCodeTemplateCaptured import com.maddyhome.idea.vim.newapi.globalIjOptions import com.maddyhome.idea.vim.newapi.vim +import com.maddyhome.idea.vim.ui.ex.ExEntryPanel import com.maddyhome.idea.vim.ui.ex.ExTextField import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString import java.awt.event.InputEvent @@ -257,7 +257,7 @@ public class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible private fun getEditor(e: AnActionEvent): Editor? { return e.getData(PlatformDataKeys.EDITOR) ?: if (e.getData(PlatformDataKeys.CONTEXT_COMPONENT) is ExTextField) { - EditorHolderService.getInstance().editor + ExEntryPanel.getInstance().editor } else { null } diff --git a/src/main/java/com/maddyhome/idea/vim/group/EditorHolderService.kt b/src/main/java/com/maddyhome/idea/vim/group/EditorHolderService.kt deleted file mode 100644 index 27e83dd436..0000000000 --- a/src/main/java/com/maddyhome/idea/vim/group/EditorHolderService.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2003-2023 The IdeaVim authors - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE.txt file or at - * https://opensource.org/licenses/MIT. - */ - -package com.maddyhome.idea.vim.group - -import com.intellij.openapi.components.Service -import com.intellij.openapi.components.service -import com.intellij.openapi.editor.Editor - -@Service -internal class EditorHolderService { - var editor: Editor? = null - - companion object { - @JvmStatic - fun getInstance(): EditorHolderService = service() - } -} diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java index 26701a3830..00b101a5d0 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExEntryPanel.java @@ -48,6 +48,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; +import java.lang.ref.WeakReference; import static com.maddyhome.idea.vim.api.VimInjectorKt.globalOptions; import static com.maddyhome.idea.vim.api.VimInjectorKt.injector; @@ -60,6 +61,7 @@ public class ExEntryPanel extends JPanel implements VimCommandLine { public static ExEntryPanel instance; public static ExEntryPanel instanceWithoutShortcuts; private boolean isReplaceMode = false; + private WeakReference weakEditor = null; private ExEntryPanel(boolean enableShortcuts) { label = new JLabel(" "); @@ -126,6 +128,18 @@ public static void fullReset() { } } + public @Nullable Editor getEditor() { + return weakEditor.get(); + } + + public void setEditor(@Nullable Editor editor) { + if (editor == null) { + weakEditor = null; + } else { + weakEditor = new WeakReference<>(editor); + } + } + /** * Turns on the ex entry field for the given editor * diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java index 7dd6022820..d1cbde5ee1 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExTextField.java @@ -16,7 +16,6 @@ import com.maddyhome.idea.vim.VimPlugin; import com.maddyhome.idea.vim.api.VimCommandLine; import com.maddyhome.idea.vim.api.VimCommandLineCaret; -import com.maddyhome.idea.vim.group.EditorHolderService; import com.maddyhome.idea.vim.helper.UiHelper; import com.maddyhome.idea.vim.history.HistoryConstants; import com.maddyhome.idea.vim.history.HistoryEntry; @@ -25,7 +24,6 @@ import com.maddyhome.idea.vim.options.helpers.GuiCursorMode; import com.maddyhome.idea.vim.options.helpers.GuiCursorOptionHelper; import com.maddyhome.idea.vim.options.helpers.GuiCursorType; -import kotlin.text.StringsKt; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -83,7 +81,7 @@ void reset() { void deactivate() { clearCurrentAction(); - EditorHolderService.getInstance().setEditor(null); + ExEntryPanel.getInstance().setEditor(null); context = null; } @@ -209,11 +207,11 @@ private void setFontToJField(String stringToDisplay) { void setEditor(@NotNull Editor editor, DataContext context) { this.context = context; - EditorHolderService.getInstance().setEditor(editor); + ExEntryPanel.getInstance().setEditor(editor); } public Editor getEditor() { - return EditorHolderService.getInstance().getEditor(); + return ExEntryPanel.getInstance().getEditor(); } public DataContext getContext() { @@ -293,7 +291,7 @@ void escape() { */ void cancel() { clearCurrentAction(); - Editor editor = EditorHolderService.getInstance().getEditor(); + Editor editor = ExEntryPanel.instance.getEditor(); if (editor != null) { VimPlugin.getProcess().cancelExEntry(new IjVimEditor(editor), true); } From b17a82c96c62aeca931de09897f7f22b684cdca8 Mon Sep 17 00:00:00 2001 From: Filipp Vakhitov Date: Sun, 2 Jun 2024 20:30:58 +0300 Subject: [PATCH 13/22] Move Vimscript grammar to engine --- build.gradle.kts | 20 --------- .../vim/vimscript/parser/VimscriptParser.kt | 4 +- .../parser/visitors/CommandVisitor.kt | 18 ++++---- .../parser/visitors/ExecutableVisitor.kt | 4 +- .../parser/visitors/ExpressionVisitor.kt | 42 +++++++++---------- .../parser/visitors/ScriptVisitor.kt | 4 +- vim-engine/build.gradle.kts | 4 +- .../src}/main/antlr/Vimscript.g4 | 0 .../idea/vim/regexp/parser/VimRegexParser.kt | 4 +- .../vim/regexp/parser/error/BailErrorLexer.kt | 2 +- .../visitors/CollectionElementVisitor.kt | 4 +- .../regexp/parser/visitors/MultiVisitor.kt | 5 +-- .../regexp/parser/visitors/PatternVisitor.kt | 4 +- 13 files changed, 47 insertions(+), 68 deletions(-) rename {src => vim-engine/src}/main/antlr/Vimscript.g4 (100%) diff --git a/build.gradle.kts b/build.gradle.kts index cf64fa3c3e..8a8a6c5803 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -63,7 +63,6 @@ buildscript { } plugins { - antlr java kotlin("jvm") version "1.9.22" application @@ -87,7 +86,6 @@ ksp { afterEvaluate { // tasks.named("kspKotlin").configure { dependsOn("clean") } - tasks.named("kspKotlin").configure { dependsOn("generateGrammarSource") } tasks.named("kspTestFixturesKotlin").configure { enabled = false } tasks.named("kspTestFixturesKotlin").configure { enabled = false } tasks.named("kspTestKotlin").configure { enabled = false } @@ -122,7 +120,6 @@ dependencies { compileOnly("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") compileOnly("org.jetbrains:annotations:24.1.0") runtimeOnly("org.antlr:antlr4-runtime:$antlrVersion") - antlr("org.antlr:antlr4:$antlrVersion") // --------- Test dependencies ---------- @@ -266,25 +263,8 @@ tasks { teamCityOutputFormat.set(true) } - generateGrammarSource { - maxHeapSize = "128m" - arguments.addAll(listOf("-package", "com.maddyhome.idea.vim.vimscript.parser.generated", "-visitor")) - outputDirectory = file("src/main/java/com/maddyhome/idea/vim/vimscript/parser/generated") - } - - named("compileKotlin") { - dependsOn("generateGrammarSource") - } - named("compileTestKotlin") { - dependsOn("generateTestGrammarSource") - } - named("compileTestFixturesKotlin") { - dependsOn("generateTestFixturesGrammarSource") - } - // Add plugin open API sources to the plugin ZIP val createOpenApiSourceJar by registering(Jar::class) { - dependsOn("generateGrammarSource") // Java sources from(sourceSets.main.get().java) { include("**/com/maddyhome/idea/vim/**/*.java") diff --git a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/VimscriptParser.kt b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/VimscriptParser.kt index 89d61e68bb..003c51fb87 100644 --- a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/VimscriptParser.kt +++ b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/VimscriptParser.kt @@ -16,8 +16,8 @@ import com.maddyhome.idea.vim.vimscript.model.commands.ExCommandTree import com.maddyhome.idea.vim.vimscript.model.commands.IntellijExCommandProvider import com.maddyhome.idea.vim.vimscript.model.expressions.Expression import com.maddyhome.idea.vim.vimscript.parser.errors.IdeavimErrorListener -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptLexer -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser +import com.maddyhome.idea.vim.parser.generated.VimscriptLexer +import com.maddyhome.idea.vim.parser.generated.VimscriptParser import com.maddyhome.idea.vim.vimscript.parser.visitors.CommandVisitor import com.maddyhome.idea.vim.vimscript.parser.visitors.ExpressionVisitor import com.maddyhome.idea.vim.vimscript.parser.visitors.ScriptVisitor diff --git a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/CommandVisitor.kt b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/CommandVisitor.kt index 348f642f93..6f424d59c1 100644 --- a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/CommandVisitor.kt +++ b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/CommandVisitor.kt @@ -101,15 +101,15 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Scope import com.maddyhome.idea.vim.vimscript.model.expressions.SimpleExpression import com.maddyhome.idea.vim.vimscript.model.expressions.operators.AssignmentOperator import com.maddyhome.idea.vim.vimscript.model.expressions.operators.AssignmentOperator.Companion.getByValue -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptBaseVisitor -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.CallCommandContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.DelfunctionCommandContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.EchoCommandContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.ExprContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.OtherCommandContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.RangeContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.RangeOffsetContext +import com.maddyhome.idea.vim.parser.generated.VimscriptBaseVisitor +import com.maddyhome.idea.vim.parser.generated.VimscriptParser +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.CallCommandContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.DelfunctionCommandContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.EchoCommandContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.ExprContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.OtherCommandContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.RangeContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.RangeOffsetContext import org.antlr.v4.runtime.ParserRuleContext import java.util.stream.Collectors import kotlin.reflect.KClass diff --git a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExecutableVisitor.kt b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExecutableVisitor.kt index 8769358064..704eb3aa32 100644 --- a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExecutableVisitor.kt +++ b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExecutableVisitor.kt @@ -30,8 +30,8 @@ import com.maddyhome.idea.vim.vimscript.model.statements.loops.ContinueStatement import com.maddyhome.idea.vim.vimscript.model.statements.loops.ForLoop import com.maddyhome.idea.vim.vimscript.model.statements.loops.ForLoopWithList import com.maddyhome.idea.vim.vimscript.model.statements.loops.WhileLoop -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptBaseVisitor -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser +import com.maddyhome.idea.vim.parser.generated.VimscriptBaseVisitor +import com.maddyhome.idea.vim.parser.generated.VimscriptParser internal object ExecutableVisitor : VimscriptBaseVisitor() { diff --git a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExpressionVisitor.kt b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExpressionVisitor.kt index 448b0c3575..c79060bec4 100644 --- a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExpressionVisitor.kt +++ b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ExpressionVisitor.kt @@ -34,27 +34,27 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.UnaryExpression import com.maddyhome.idea.vim.vimscript.model.expressions.Variable import com.maddyhome.idea.vim.vimscript.model.expressions.operators.BinaryOperator import com.maddyhome.idea.vim.vimscript.model.expressions.operators.UnaryOperator -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptBaseVisitor -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.BlobExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.DictionaryExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.EnvVariableExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.FalsyExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.FloatExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.FunctionCallExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.IntExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.ListExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.LiteralDictionaryExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.OneElementSublistExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.OptionExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.RegisterExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.StringExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.SublistExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.TernaryExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.UnaryExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.VariableContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.VariableExpressionContext -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser.WrappedExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptBaseVisitor +import com.maddyhome.idea.vim.parser.generated.VimscriptParser +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.BlobExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.DictionaryExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.EnvVariableExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.FalsyExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.FloatExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.FunctionCallExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.IntExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.ListExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.LiteralDictionaryExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.OneElementSublistExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.OptionExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.RegisterExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.StringExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.SublistExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.TernaryExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.UnaryExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.VariableContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.VariableExpressionContext +import com.maddyhome.idea.vim.parser.generated.VimscriptParser.WrappedExpressionContext import org.antlr.v4.runtime.ParserRuleContext internal object ExpressionVisitor : VimscriptBaseVisitor() { diff --git a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ScriptVisitor.kt b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ScriptVisitor.kt index 6d26b1fe75..aa97822746 100644 --- a/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ScriptVisitor.kt +++ b/src/main/java/com/maddyhome/idea/vim/vimscript/parser/visitors/ScriptVisitor.kt @@ -9,8 +9,8 @@ package com.maddyhome.idea.vim.vimscript.parser.visitors import com.maddyhome.idea.vim.vimscript.model.Script -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptBaseVisitor -import com.maddyhome.idea.vim.vimscript.parser.generated.VimscriptParser +import com.maddyhome.idea.vim.parser.generated.VimscriptBaseVisitor +import com.maddyhome.idea.vim.parser.generated.VimscriptParser internal object ScriptVisitor : VimscriptBaseVisitor