mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2026-10-17 05:33:52 +02:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d7dada898
|
||
|
|
649e6aac8c
|
||
|
|
8e5bee5eb3
|
||
|
|
19a1ad698c
|
||
|
|
5d79c93e4e
|
||
|
|
08cb48682d
|
||
|
|
d0ccad28c9
|
+1
-1
@@ -18,7 +18,7 @@ ideaVersion=2026.1
|
||||
# Values for type: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type
|
||||
ideaType=IU
|
||||
instrumentPluginCode=true
|
||||
version=chylex-1
|
||||
version=9999.60-chylex
|
||||
javaVersion=21
|
||||
remoteRobotVersion=0.11.23
|
||||
antlrVersion=4.10.1
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
package com.maddyhome.idea.vim.helper
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.util.SystemInfoRt
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.ui.KeyStrokeAdapter
|
||||
import java.awt.event.InputEvent
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
@@ -24,12 +27,30 @@ internal class ActionEventKeyStrokeExtractor {
|
||||
val defaultKeyStroke = KeyStrokeAdapter.getDefaultKeyStroke(inputEvent)
|
||||
val strokeCache = keyStrokeCache
|
||||
if (defaultKeyStroke != null) {
|
||||
keyStrokeCache = inputEvent.`when` to defaultKeyStroke
|
||||
return defaultKeyStroke
|
||||
val fixedKeyStroke = fixKeyStroke(defaultKeyStroke)
|
||||
keyStrokeCache = inputEvent.`when` to fixedKeyStroke
|
||||
return fixedKeyStroke
|
||||
} else if (strokeCache.first == inputEvent.`when`) {
|
||||
keyStrokeCache = null to null
|
||||
return strokeCache.second
|
||||
}
|
||||
return KeyStroke.getKeyStrokeForEvent(inputEvent)
|
||||
}
|
||||
|
||||
private fun fixKeyStroke(key: KeyStroke): KeyStroke {
|
||||
return if (
|
||||
key.modifiers and CTRL_ALT_MASK != 0 &&
|
||||
key.isOnKeyRelease &&
|
||||
SystemInfoRt.isWindows &&
|
||||
Registry.`is`("actionSystem.fix.alt.gr", true)
|
||||
) {
|
||||
KeyStroke.getKeyStroke(key.keyCode, key.modifiers)
|
||||
} else {
|
||||
key
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CTRL_ALT_MASK = InputEvent.CTRL_DOWN_MASK or InputEvent.ALT_DOWN_MASK
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ public class EditorHelper {
|
||||
|
||||
private static int getStickyLinesPanelHeight(final @NotNull Editor editor) {
|
||||
if (editor instanceof EditorImpl editorImpl) {
|
||||
return editorImpl.getStickyLinesPanelHeight();
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.EditorKind
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil
|
||||
import com.intellij.util.ui.table.JBTableRowEditor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.StringListOptionValue
|
||||
@@ -74,6 +75,10 @@ internal val Editor.isIdeaVimDisabledHere: Boolean
|
||||
* allowed again, because blocking every non-file editor also took Vim away from the process console.
|
||||
*/
|
||||
private fun Editor.isAllowedFileEditor(): Boolean {
|
||||
if (EditorHelper.getVirtualFile(this)?.name?.contains("Dummy.txt") == true) {
|
||||
return PopupUtil.getPopupContainerFor(component) == null
|
||||
}
|
||||
|
||||
return EditorHelper.isCommitWindowEditor(this)
|
||||
|| EditorHelper.isKotlinClassDecompiledToJavaFile(this)
|
||||
|| EditorHelper.isDiffEditor(this)
|
||||
|
||||
@@ -198,6 +198,11 @@ private fun updateSearchHighlights(
|
||||
currentMatchOffset,
|
||||
editor
|
||||
)
|
||||
|
||||
if (!isIncsearch) {
|
||||
removeHighlightsEditors.add(editor)
|
||||
removeHighlightsTimer.restart()
|
||||
}
|
||||
}
|
||||
|
||||
return currentEditorCurrentMatchOffset
|
||||
@@ -377,3 +382,9 @@ private fun shouldAddCurrentMatchSearchHighlight(pattern: String?, hlSearch: Boo
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
private fun isIncrementalSearchHighlights(initialOffset: Int) = initialOffset != -1
|
||||
|
||||
val removeHighlightsEditors = mutableListOf<Editor>()
|
||||
val removeHighlightsTimer = javax.swing.Timer(450) {
|
||||
removeHighlightsEditors.forEach(::removeSearchHighlights)
|
||||
removeHighlightsEditors.clear()
|
||||
}
|
||||
|
||||
@@ -417,16 +417,18 @@ object VimListenerManager {
|
||||
editorGroup?.editorDeinit(editor.vim)
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
if (vimDisabled(editor)) {
|
||||
remove(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun remove(editor: Editor) {
|
||||
val editorDisposable = editor.removeUserData(editorListenersDisposableKey)
|
||||
if (editorDisposable != null) {
|
||||
Disposer.dispose(editorDisposable)
|
||||
} else if (!EditorHelper.isCommandHistoryWindow(editor)) {
|
||||
// Cmdwin editors (q:, q/, q?) may bypass `add` in some test paths; that's expected.
|
||||
// We definitely do not expect this to happen for any other editor.
|
||||
StrictMode.fail("Editor doesn't have disposable attached. $editor")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,7 +543,7 @@ object VimListenerManager {
|
||||
|
||||
MotionGroup.fileEditorManagerSelectionChangedCallback(event)
|
||||
FileGroupHelper.fileEditorManagerSelectionChangedCallback(event)
|
||||
VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
||||
// VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
||||
IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event)
|
||||
VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor)
|
||||
}
|
||||
|
||||
@@ -100,8 +100,7 @@ abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
* Vim's `did_ai`: the indent on the caret's line was inserted automatically and nothing has been typed since, so it
|
||||
* is removed again when Insert mode is left. Only valid for the current insert session
|
||||
*/
|
||||
@JvmField
|
||||
protected var didAutoIndent: Boolean = false
|
||||
protected var didAutoIndent: Boolean get() = false; set(_) = Unit
|
||||
|
||||
/**
|
||||
* The value [didAutoIndent] gets when the next insert session starts.
|
||||
@@ -389,11 +388,13 @@ abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
caret.moveToOffset(position)
|
||||
} else {
|
||||
repeatInsertText(editor, context, count)
|
||||
if (!(editor.charAt(caret.offset) == '\n' && editor.charAt(caret.offset - 1).let { it == ' ' || it == '\t' })) {
|
||||
val position = injector.motion.getHorizontalMotion(editor, caret, -1, false)
|
||||
caret.moveToMotion(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repeatLines = 0
|
||||
repeatColumn = 0
|
||||
repeatAppend = false
|
||||
|
||||
Reference in New Issue
Block a user