1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-29 20:53:09 +02:00

Disable IdeaVim listeners in places where IdeaVim is disabled

This is needed for the new terminal. Before this change, it was impossible to put the caret at the line end, even taking the fact the IdeaVim is disabled in the new terminal.
This commit is contained in:
Alex Plate
2025-02-14 17:59:06 +02:00
parent 693bb50d5e
commit 83b92d84a6
2 changed files with 14 additions and 4 deletions
src/main/java/com/maddyhome/idea/vim/listener

@@ -22,6 +22,7 @@ import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.group.visual.IdeaSelectionControl
import com.maddyhome.idea.vim.group.visual.moveCaretOneCharLeftFromSelectionEnd
import com.maddyhome.idea.vim.helper.getTopLevelEditor
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
internal class RiderActionListener : AnActionListener {
@@ -45,9 +46,11 @@ internal class RiderActionListener : AnActionListener {
editor?.caretModel?.addCaretListener(object : CaretListener {
override fun caretPositionChanged(event: CaretEvent) {
val eventEditor = event.editor.getTopLevelEditor()
val predictedMode =
IdeaSelectionControl.predictMode(eventEditor, VimListenerManager.SelectionSource.OTHER)
moveCaretOneCharLeftFromSelectionEnd(eventEditor, predictedMode)
if (!eventEditor.isIdeaVimDisabledHere) {
val predictedMode =
IdeaSelectionControl.predictMode(eventEditor, VimListenerManager.SelectionSource.OTHER)
moveCaretOneCharLeftFromSelectionEnd(eventEditor, predictedMode)
}
eventEditor.caretModel.removeCaretListener(this)
}
})

@@ -87,6 +87,7 @@ import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.forceBarCursor
import com.maddyhome.idea.vim.helper.inVisualMode
import com.maddyhome.idea.vim.helper.isEndAllowed
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.resetVimLastColumn
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
@@ -642,7 +643,9 @@ internal object VimListenerManager {
private var cutOffFixed = false
override fun mouseDragged(e: EditorMouseEvent) {
val caret = e.editor.caretModel.primaryCaret
val editor = e.editor
if (editor.isIdeaVimDisabledHere) return
val caret = editor.caretModel.primaryCaret
clearFirstSelectionEvents(e)
@@ -734,6 +737,7 @@ internal object VimListenerManager {
}
override fun mousePressed(event: EditorMouseEvent) {
if (event.editor.isIdeaVimDisabledHere) return
MouseEventsDataHolder.dragEventCount = MouseEventsDataHolder.allowedSkippedDragEvents
SelectionVimListenerSuppressor.reset()
}
@@ -745,6 +749,7 @@ internal object VimListenerManager {
* - Click-hold and switch editor (ctrl-tab)
*/
override fun mouseReleased(event: EditorMouseEvent) {
if (event.editor.isIdeaVimDisabledHere) return
SelectionVimListenerSuppressor.unlock()
clearFirstSelectionEvents(event)
@@ -768,6 +773,7 @@ internal object VimListenerManager {
}
override fun mouseClicked(event: EditorMouseEvent) {
if (event.editor.isIdeaVimDisabledHere) return
logger.debug("Mouse clicked")
if (event.area == EditorMouseEventArea.EDITING_AREA) {
@@ -829,6 +835,7 @@ internal object VimListenerManager {
override fun mousePressed(e: MouseEvent?) {
val editor = (e?.component as? EditorComponentImpl)?.editor ?: return
if (editor.isIdeaVimDisabledHere) return
val predictedMode = IdeaSelectionControl.predictMode(editor, SelectionSource.MOUSE)
when (e.clickCount) {
1 -> {