mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2026-10-16 20:33:57 +02:00
Compare commits
8
Commits
7d7dada898
...
d9b8a4fb13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9b8a4fb13
|
||
|
|
75bfa61925
|
||
|
|
200ec346d0
|
||
|
|
372a105edc
|
||
|
|
898c8f5fab
|
||
|
|
a772fd0b05
|
||
|
|
6c4c4d1050
|
||
|
|
b28c2690e7
|
+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
|
# Values for type: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type
|
||||||
ideaType=IU
|
ideaType=IU
|
||||||
instrumentPluginCode=true
|
instrumentPluginCode=true
|
||||||
version=chylex-1
|
version=9999.61-chylex
|
||||||
javaVersion=21
|
javaVersion=21
|
||||||
remoteRobotVersion=0.11.23
|
remoteRobotVersion=0.11.23
|
||||||
antlrVersion=4.10.1
|
antlrVersion=4.10.1
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
package com.maddyhome.idea.vim.helper
|
package com.maddyhome.idea.vim.helper
|
||||||
|
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
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 com.intellij.ui.KeyStrokeAdapter
|
||||||
|
import java.awt.event.InputEvent
|
||||||
import java.awt.event.KeyEvent
|
import java.awt.event.KeyEvent
|
||||||
import javax.swing.KeyStroke
|
import javax.swing.KeyStroke
|
||||||
|
|
||||||
@@ -24,12 +27,30 @@ internal class ActionEventKeyStrokeExtractor {
|
|||||||
val defaultKeyStroke = KeyStrokeAdapter.getDefaultKeyStroke(inputEvent)
|
val defaultKeyStroke = KeyStrokeAdapter.getDefaultKeyStroke(inputEvent)
|
||||||
val strokeCache = keyStrokeCache
|
val strokeCache = keyStrokeCache
|
||||||
if (defaultKeyStroke != null) {
|
if (defaultKeyStroke != null) {
|
||||||
keyStrokeCache = inputEvent.`when` to defaultKeyStroke
|
val fixedKeyStroke = fixKeyStroke(defaultKeyStroke)
|
||||||
return defaultKeyStroke
|
keyStrokeCache = inputEvent.`when` to fixedKeyStroke
|
||||||
|
return fixedKeyStroke
|
||||||
} else if (strokeCache.first == inputEvent.`when`) {
|
} else if (strokeCache.first == inputEvent.`when`) {
|
||||||
keyStrokeCache = null to null
|
keyStrokeCache = null to null
|
||||||
return strokeCache.second
|
return strokeCache.second
|
||||||
}
|
}
|
||||||
return KeyStroke.getKeyStrokeForEvent(inputEvent)
|
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) {
|
private static int getStickyLinesPanelHeight(final @NotNull Editor editor) {
|
||||||
if (editor instanceof EditorImpl editorImpl) {
|
if (editor instanceof EditorImpl editorImpl) {
|
||||||
return editorImpl.getStickyLinesPanelHeight();
|
return 0;
|
||||||
}
|
}
|
||||||
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.EditorKind
|
||||||
import com.intellij.openapi.editor.ex.util.EditorUtil
|
import com.intellij.openapi.editor.ex.util.EditorUtil
|
||||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||||
|
import com.intellij.openapi.ui.popup.util.PopupUtil
|
||||||
import com.intellij.util.ui.table.JBTableRowEditor
|
import com.intellij.util.ui.table.JBTableRowEditor
|
||||||
import com.maddyhome.idea.vim.VimPlugin
|
import com.maddyhome.idea.vim.VimPlugin
|
||||||
import com.maddyhome.idea.vim.api.StringListOptionValue
|
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.
|
* allowed again, because blocking every non-file editor also took Vim away from the process console.
|
||||||
*/
|
*/
|
||||||
private fun Editor.isAllowedFileEditor(): Boolean {
|
private fun Editor.isAllowedFileEditor(): Boolean {
|
||||||
|
if (EditorHelper.getVirtualFile(this)?.name?.contains("Dummy.txt") == true) {
|
||||||
|
return PopupUtil.getPopupContainerFor(component) == null
|
||||||
|
}
|
||||||
|
|
||||||
return EditorHelper.isCommitWindowEditor(this)
|
return EditorHelper.isCommitWindowEditor(this)
|
||||||
|| EditorHelper.isKotlinClassDecompiledToJavaFile(this)
|
|| EditorHelper.isKotlinClassDecompiledToJavaFile(this)
|
||||||
|| EditorHelper.isDiffEditor(this)
|
|| EditorHelper.isDiffEditor(this)
|
||||||
|
|||||||
@@ -198,6 +198,11 @@ private fun updateSearchHighlights(
|
|||||||
currentMatchOffset,
|
currentMatchOffset,
|
||||||
editor
|
editor
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!isIncsearch) {
|
||||||
|
removeHighlightsEditors.add(editor)
|
||||||
|
removeHighlightsTimer.restart()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentEditorCurrentMatchOffset
|
return currentEditorCurrentMatchOffset
|
||||||
@@ -377,3 +382,9 @@ private fun shouldAddCurrentMatchSearchHighlight(pattern: String?, hlSearch: Boo
|
|||||||
*/
|
*/
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
private fun isIncrementalSearchHighlights(initialOffset: Int) = initialOffset != -1
|
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)
|
editorGroup?.editorDeinit(editor.vim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ApplicationManager.getApplication().invokeLater {
|
||||||
|
if (vimDisabled(editor)) {
|
||||||
|
remove(editor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(editor: Editor) {
|
fun remove(editor: Editor) {
|
||||||
val editorDisposable = editor.removeUserData(editorListenersDisposableKey)
|
val editorDisposable = editor.removeUserData(editorListenersDisposableKey)
|
||||||
if (editorDisposable != null) {
|
if (editorDisposable != null) {
|
||||||
Disposer.dispose(editorDisposable)
|
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)
|
MotionGroup.fileEditorManagerSelectionChangedCallback(event)
|
||||||
FileGroupHelper.fileEditorManagerSelectionChangedCallback(event)
|
FileGroupHelper.fileEditorManagerSelectionChangedCallback(event)
|
||||||
VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
// VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
||||||
IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event)
|
IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event)
|
||||||
VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor)
|
VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor)
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.vimscript.model.functions.handlers
|
||||||
|
|
||||||
|
import com.intellij.refactoring.rename.inplace.InplaceRefactoring
|
||||||
|
import com.intellij.vim.annotations.VimscriptFunction
|
||||||
|
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||||
|
import com.maddyhome.idea.vim.api.VimEditor
|
||||||
|
import com.maddyhome.idea.vim.newapi.ij
|
||||||
|
import com.maddyhome.idea.vim.vimscript.model.VimLContext
|
||||||
|
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
||||||
|
import com.maddyhome.idea.vim.vimscript.model.datatypes.asVimInt
|
||||||
|
import com.maddyhome.idea.vim.vimscript.model.functions.BuiltinFunctionHandler
|
||||||
|
|
||||||
|
@VimscriptFunction(name = "isinplacerenaming")
|
||||||
|
internal class IsInPlaceRenaming : BuiltinFunctionHandler<VimInt>() {
|
||||||
|
override fun doFunction(arguments: Arguments, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext) =
|
||||||
|
(InplaceRefactoring.getActiveInplaceRenamer(editor.ij) != null).asVimInt()
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"has": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler",
|
"has": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler",
|
||||||
"isactionenabled": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.IsActionEnabled",
|
"isactionenabled": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.IsActionEnabled",
|
||||||
|
"isinplacerenaming": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.IsInPlaceRenaming",
|
||||||
"pumvisible": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.PopupMenuVisibleFunctionHandler"
|
"pumvisible": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.PopupMenuVisibleFunctionHandler"
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ import com.maddyhome.idea.vim.helper.CharacterHelper.charType
|
|||||||
import com.maddyhome.idea.vim.helper.NumberType
|
import com.maddyhome.idea.vim.helper.NumberType
|
||||||
import com.maddyhome.idea.vim.helper.StrictMode
|
import com.maddyhome.idea.vim.helper.StrictMode
|
||||||
import com.maddyhome.idea.vim.helper.endOffsetInclusive
|
import com.maddyhome.idea.vim.helper.endOffsetInclusive
|
||||||
|
import com.maddyhome.idea.vim.helper.isCaretAtLineEnd
|
||||||
import com.maddyhome.idea.vim.helper.usesVirtualSpace
|
import com.maddyhome.idea.vim.helper.usesVirtualSpace
|
||||||
import com.maddyhome.idea.vim.key.AbbreviationContext
|
import com.maddyhome.idea.vim.key.AbbreviationContext
|
||||||
import com.maddyhome.idea.vim.key.findAndResolveAbbreviation
|
import com.maddyhome.idea.vim.key.findAndResolveAbbreviation
|
||||||
@@ -100,8 +101,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
|
* 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
|
* is removed again when Insert mode is left. Only valid for the current insert session
|
||||||
*/
|
*/
|
||||||
@JvmField
|
protected var didAutoIndent: Boolean get() = false; set(_) = Unit
|
||||||
protected var didAutoIndent: Boolean = false
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value [didAutoIndent] gets when the next insert session starts.
|
* The value [didAutoIndent] gets when the next insert session starts.
|
||||||
@@ -389,8 +389,10 @@ abstract class VimChangeGroupBase : VimChangeGroup {
|
|||||||
caret.moveToOffset(position)
|
caret.moveToOffset(position)
|
||||||
} else {
|
} else {
|
||||||
repeatInsertText(editor, context, count)
|
repeatInsertText(editor, context, count)
|
||||||
val position = injector.motion.getHorizontalMotion(editor, caret, -1, false)
|
if (!(editor.isCaretAtLineEnd(caret, true) && editor.charAt(caret.offset - 1).let { it == ' ' || it == '\t' })) {
|
||||||
caret.moveToMotion(position)
|
val position = injector.motion.getHorizontalMotion(editor, caret, -1, false)
|
||||||
|
caret.moveToMotion(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user