1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-22 01:34:04 +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
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 14 additions and 4 deletions
src/main/java/com/maddyhome/idea/vim/listener

View File

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

View File

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