mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
24 Commits
customized
...
customized
Author | SHA1 | Date | |
---|---|---|---|
295f0b6c53
|
|||
2643301ea9
|
|||
51f15782af
|
|||
de930ed57c
|
|||
590d5bd22d
|
|||
69c748d881
|
|||
144cc5c3fc
|
|||
fb270cdbc5
|
|||
ce6a296233
|
|||
949f359b98
|
|||
c922426e02
|
|||
9240e82f2d
|
|||
a1639d80b0
|
|||
7860b98107
|
|||
7157f9c5a5
|
|||
1522618cd6
|
|||
09862c8356
|
|||
c6ef3f286f
|
|||
b358e63444
|
|||
7ac743c604
|
|||
db3d3fc608
|
|||
14d313907b
|
|||
fe37a69544
|
|||
54de3dac25
|
@@ -127,7 +127,7 @@ dependencies {
|
||||
|
||||
// AceJump is an optional dependency. We use their SessionManager class to check if it's active
|
||||
plugin("AceJump", "3.8.19")
|
||||
plugin("com.intellij.classic.ui", "242.20224.159")
|
||||
plugin("com.intellij.classic.ui", "243.21565.122")
|
||||
|
||||
bundledPlugins("org.jetbrains.plugins.terminal", "com.intellij.modules.json")
|
||||
}
|
||||
|
@@ -16,11 +16,11 @@
|
||||
# https://data.services.jetbrains.com/products?code=IC
|
||||
# Maven releases are here: https://www.jetbrains.com/intellij-repository/releases
|
||||
# And snapshots: https://www.jetbrains.com/intellij-repository/snapshots
|
||||
ideaVersion=2024.3.3
|
||||
ideaVersion=2024.3
|
||||
# Values for type: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type
|
||||
ideaType=IC
|
||||
instrumentPluginCode=true
|
||||
version=chylex-43
|
||||
version=chylex-45
|
||||
javaVersion=21
|
||||
remoteRobotVersion=0.11.23
|
||||
antlrVersion=4.10.1
|
||||
|
@@ -182,6 +182,9 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
|
||||
}
|
||||
|
||||
if (editor.inInsertMode) {
|
||||
if (keyCode == KeyEvent.VK_ENTER) {
|
||||
return ActionEnableStatus.no("Enter action in insert mode", LogLevel.INFO)
|
||||
}
|
||||
if (keyCode == KeyEvent.VK_TAB) {
|
||||
// TODO: This stops VimEditorTab seeing <Tab> in insert mode and correctly scrolling the view
|
||||
// There are multiple actions registered for VK_TAB. The important items, in order, are this, the Live
|
||||
|
@@ -38,6 +38,7 @@ import com.maddyhome.idea.vim.api.VimActionExecutor
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase
|
||||
import com.maddyhome.idea.vim.ide.isRider
|
||||
import com.maddyhome.idea.vim.newapi.IjNativeAction
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import com.maddyhome.idea.vim.newapi.runFromVimKey
|
||||
@@ -76,7 +77,7 @@ internal class IjActionExecutor : VimActionExecutor {
|
||||
}
|
||||
|
||||
val ijAction = (action as IjNativeAction).action
|
||||
if (Registry.`is`("ideavim.old.action.execution", true)) {
|
||||
if (Registry.`is`("ideavim.old.action.execution", true) || isRider()) {
|
||||
return manualActionExecution(context, ijAction)
|
||||
} else {
|
||||
try {
|
||||
|
@@ -17,6 +17,7 @@ import com.intellij.openapi.editor.markup.HighlighterLayer
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter
|
||||
import com.intellij.openapi.editor.markup.TextAttributes
|
||||
import com.intellij.util.application
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.globalOptions
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
@@ -30,6 +31,7 @@ import com.maddyhome.idea.vim.state.mode.inVisualMode
|
||||
import org.jetbrains.annotations.Contract
|
||||
import java.awt.Font
|
||||
import java.util.*
|
||||
import javax.swing.Timer
|
||||
|
||||
internal fun updateSearchHighlights(
|
||||
pattern: String?,
|
||||
@@ -84,6 +86,12 @@ internal fun addSubstitutionConfirmationHighlight(editor: Editor, start: Int, en
|
||||
)
|
||||
}
|
||||
|
||||
val removeHighlightsEditors = mutableListOf<Editor>()
|
||||
val removeHighlightsTimer = Timer(400) {
|
||||
removeHighlightsEditors.forEach(::removeSearchHighlights)
|
||||
removeHighlightsEditors.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes current search highlights for all visible editors
|
||||
*/
|
||||
@@ -125,27 +133,43 @@ private fun updateSearchHighlights(
|
||||
// hlsearch (+ incsearch/noincsearch)
|
||||
// Make sure the range fits this editor. Note that Vim will use the same range for all windows. E.g., given
|
||||
// `:1,5s/foo`, Vim will highlight all occurrences of `foo` in the first five lines of all visible windows
|
||||
val vimEditor = editor.vim
|
||||
val editorLastLine = vimEditor.lineCount() - 1
|
||||
val searchStartLine = searchRange?.startLine ?: 0
|
||||
val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine)
|
||||
if (searchStartLine <= editorLastLine) {
|
||||
val results =
|
||||
injector.searchHelper.findAll(
|
||||
vimEditor,
|
||||
pattern,
|
||||
searchStartLine,
|
||||
searchEndLine,
|
||||
shouldIgnoreCase(pattern, shouldIgnoreSmartCase)
|
||||
)
|
||||
if (results.isNotEmpty()) {
|
||||
if (editor === currentEditor?.ij) {
|
||||
currentMatchOffset = findClosestMatch(results, initialOffset, count1, forwards)
|
||||
val isSearching = injector.commandLine.getActiveCommandLine() != null
|
||||
application.invokeLater {
|
||||
val vimEditor = editor.vim
|
||||
val editorLastLine = vimEditor.lineCount() - 1
|
||||
val searchStartLine = searchRange?.startLine ?: 0
|
||||
val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine)
|
||||
if (searchStartLine <= editorLastLine) {
|
||||
val visibleArea = editor.scrollingModel.visibleAreaOnScrollingFinished
|
||||
val visibleTopLeft = visibleArea.location
|
||||
val visibleBottomRight = visibleArea.location.apply { translate(visibleArea.width, visibleArea.height) }
|
||||
val visibleStartOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(visibleTopLeft))
|
||||
val visibleEndOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(visibleBottomRight))
|
||||
val visibleStartLine = editor.document.getLineNumber(visibleStartOffset)
|
||||
val visibleEndLine = editor.document.getLineNumber(visibleEndOffset)
|
||||
removeSearchHighlights(editor)
|
||||
|
||||
val results =
|
||||
injector.searchHelper.findAll(
|
||||
vimEditor,
|
||||
pattern,
|
||||
searchStartLine.coerceAtLeast(visibleStartLine),
|
||||
searchEndLine.coerceAtMost(visibleEndLine),
|
||||
shouldIgnoreCase(pattern, shouldIgnoreSmartCase)
|
||||
)
|
||||
if (results.isNotEmpty()) {
|
||||
if (editor === currentEditor?.ij) {
|
||||
currentMatchOffset = findClosestMatch(results, initialOffset, count1, forwards)
|
||||
}
|
||||
highlightSearchResults(editor, pattern, results, currentMatchOffset)
|
||||
if (!isSearching) {
|
||||
removeHighlightsEditors.add(editor)
|
||||
removeHighlightsTimer.restart()
|
||||
}
|
||||
}
|
||||
highlightSearchResults(editor, pattern, results, currentMatchOffset)
|
||||
}
|
||||
editor.vimLastSearch = pattern
|
||||
}
|
||||
editor.vimLastSearch = pattern
|
||||
} else if (shouldAddCurrentMatchSearchHighlight(pattern, showHighlights, initialOffset)) {
|
||||
// nohlsearch + incsearch. Even though search highlights are disabled, we still show a highlight (current editor
|
||||
// only), because 'incsearch' is active. But we don't show a search if Visual is active (behind Command-line of
|
||||
@@ -179,6 +203,7 @@ private fun updateSearchHighlights(
|
||||
}
|
||||
}
|
||||
|
||||
removeHighlightsTimer.restart()
|
||||
return currentEditorCurrentMatchOffset
|
||||
}
|
||||
|
||||
@@ -204,7 +229,7 @@ private fun removeSearchHighlights(editor: Editor) {
|
||||
*/
|
||||
@Contract("_, _, false -> false; _, null, true -> false")
|
||||
private fun shouldAddAllSearchHighlights(editor: Editor, newPattern: String?, hlSearch: Boolean): Boolean {
|
||||
return hlSearch && newPattern != null && newPattern != editor.vimLastSearch && newPattern != ""
|
||||
return hlSearch && newPattern != null && newPattern != ""
|
||||
}
|
||||
|
||||
private fun findClosestMatch(
|
||||
|
@@ -425,7 +425,7 @@ internal object VimListenerManager {
|
||||
|
||||
MotionGroup.fileEditorManagerSelectionChangedCallback(event)
|
||||
FileGroup.fileEditorManagerSelectionChangedCallback(event)
|
||||
VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
||||
// VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
|
||||
IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event)
|
||||
VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor)
|
||||
}
|
||||
|
@@ -31,6 +31,12 @@ class MotionCamelLeftAction : MotionActionHandler.ForEachCaret() {
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
if (caret.hasSelection() && caret.offset > caret.vimSelectionStart) {
|
||||
val target = injector.searchHelper.findPreviousCamelEnd(editor.text(), caret.offset, operatorArguments.count1)
|
||||
if (target != null && target > caret.vimSelectionStart) {
|
||||
return target.toMotionOrError()
|
||||
}
|
||||
}
|
||||
return injector.searchHelper.findPreviousCamelStart(editor.text(), caret.offset, operatorArguments.count1)
|
||||
?.toMotionOrError() ?: Motion.Error
|
||||
}
|
||||
@@ -47,6 +53,10 @@ class MotionCamelRightAction : MotionActionHandler.ForEachCaret() {
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
if (caret.hasSelection() && caret.offset >= caret.vimSelectionStart) {
|
||||
return injector.searchHelper.findNextCamelEnd(editor.text(), caret.offset + 1, operatorArguments.count1)
|
||||
?.toMotionOrError() ?: Motion.Error
|
||||
}
|
||||
return injector.searchHelper.findNextCamelStart(editor.text(), caret.offset + 1, operatorArguments.count1)
|
||||
?.toMotionOrError() ?: Motion.Error
|
||||
}
|
||||
|
Reference in New Issue
Block a user