1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-04-18 16:15:47 +02:00

Compare commits

..

22 Commits

Author SHA1 Message Date
7c7e7728f2
Set plugin version to chylex-44 2025-03-25 09:25:25 +01:00
de930ed57c
Make search highlights temporary 2025-03-25 09:25:25 +01:00
590d5bd22d
Exit insert mode after refactoring 2025-03-25 09:25:25 +01:00
69c748d881
Add action to run last macro in all opened files 2025-03-25 09:25:25 +01:00
144cc5c3fc
Stop macro execution after a failed search 2025-03-25 09:25:24 +01:00
fb270cdbc5
Revert per-caret registers 2025-03-25 09:25:24 +01:00
ce6a296233
Fix(VIM-3364): Exception with mapped Generate action 2025-03-25 09:25:24 +01:00
949f359b98
Apply scrolloff after executing native IDEA actions 2025-03-25 09:25:24 +01:00
c922426e02
Stay on same line after reindenting 2025-03-25 09:25:24 +01:00
9240e82f2d
Update search register when using f/t 2025-03-25 09:25:24 +01:00
a1639d80b0
Automatically add unambiguous imports after running a macro 2025-03-25 09:25:24 +01:00
7860b98107
Fix(VIM-3179): Respect virtual space below editor (imperfectly) 2025-03-25 09:25:24 +01:00
7157f9c5a5
Fix(VIM-3178): Workaround to support "Jump to Source" action mapping 2025-03-25 09:25:24 +01:00
1522618cd6
Add support for count for visual and line motion surround 2025-03-25 09:25:24 +01:00
09862c8356
Fix vim-surround not working with multiple cursors
Fixes multiple cursors with vim-surround commands `cs, ds, S` (but not `ys`).
2025-03-25 09:25:24 +01:00
c6ef3f286f
Fix(VIM-696) Restore visual mode after undo/redo, and disable incompatible actions 2025-03-25 09:25:24 +01:00
b358e63444
Respect count with <Action> mappings 2025-03-25 09:25:24 +01:00
7ac743c604
Change matchit plugin to use HTML patterns in unrecognized files 2025-03-25 09:25:24 +01:00
db3d3fc608
Reset insert mode when switching active editor 2025-03-25 09:25:24 +01:00
14d313907b
Remove notifications about configuration options 2025-03-25 09:25:24 +01:00
fe37a69544
Remove update checker 2025-03-25 09:25:24 +01:00
54de3dac25
Set custom plugin version 2025-03-25 09:25:24 +01:00
4 changed files with 48 additions and 23 deletions

View File

@ -127,7 +127,7 @@ dependencies {
// AceJump is an optional dependency. We use their SessionManager class to check if it's active // AceJump is an optional dependency. We use their SessionManager class to check if it's active
plugin("AceJump", "3.8.19") 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") bundledPlugins("org.jetbrains.plugins.terminal", "com.intellij.modules.json")
} }

View File

@ -16,11 +16,11 @@
# https://data.services.jetbrains.com/products?code=IC # https://data.services.jetbrains.com/products?code=IC
# Maven releases are here: https://www.jetbrains.com/intellij-repository/releases # Maven releases are here: https://www.jetbrains.com/intellij-repository/releases
# And snapshots: https://www.jetbrains.com/intellij-repository/snapshots # 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 # Values for type: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type
ideaType=IC ideaType=IC
instrumentPluginCode=true instrumentPluginCode=true
version=chylex-43 version=chylex-44
javaVersion=21 javaVersion=21
remoteRobotVersion=0.11.23 remoteRobotVersion=0.11.23
antlrVersion=4.10.1 antlrVersion=4.10.1

View File

@ -17,6 +17,7 @@ import com.intellij.openapi.editor.markup.HighlighterLayer
import com.intellij.openapi.editor.markup.HighlighterTargetArea import com.intellij.openapi.editor.markup.HighlighterTargetArea
import com.intellij.openapi.editor.markup.RangeHighlighter import com.intellij.openapi.editor.markup.RangeHighlighter
import com.intellij.openapi.editor.markup.TextAttributes 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.VimEditor
import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector 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 org.jetbrains.annotations.Contract
import java.awt.Font import java.awt.Font
import java.util.* import java.util.*
import javax.swing.Timer
internal fun updateSearchHighlights( internal fun updateSearchHighlights(
pattern: String?, 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 * Refreshes current search highlights for all visible editors
*/ */
@ -125,27 +133,43 @@ private fun updateSearchHighlights(
// hlsearch (+ incsearch/noincsearch) // hlsearch (+ incsearch/noincsearch)
// Make sure the range fits this editor. Note that Vim will use the same range for all windows. E.g., given // 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 // `:1,5s/foo`, Vim will highlight all occurrences of `foo` in the first five lines of all visible windows
val vimEditor = editor.vim val isSearching = injector.commandLine.getActiveCommandLine() != null
val editorLastLine = vimEditor.lineCount() - 1 application.invokeLater {
val searchStartLine = searchRange?.startLine ?: 0 val vimEditor = editor.vim
val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine) val editorLastLine = vimEditor.lineCount() - 1
if (searchStartLine <= editorLastLine) { val searchStartLine = searchRange?.startLine ?: 0
val results = val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine)
injector.searchHelper.findAll( if (searchStartLine <= editorLastLine) {
vimEditor, val visibleArea = editor.scrollingModel.visibleAreaOnScrollingFinished
pattern, val visibleTopLeft = visibleArea.location
searchStartLine, val visibleBottomRight = visibleArea.location.apply { translate(visibleArea.width, visibleArea.height) }
searchEndLine, val visibleStartOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(visibleTopLeft))
shouldIgnoreCase(pattern, shouldIgnoreSmartCase) val visibleEndOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(visibleBottomRight))
) val visibleStartLine = editor.document.getLineNumber(visibleStartOffset)
if (results.isNotEmpty()) { val visibleEndLine = editor.document.getLineNumber(visibleEndOffset)
if (editor === currentEditor?.ij) { removeSearchHighlights(editor)
currentMatchOffset = findClosestMatch(results, initialOffset, count1, forwards)
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)) { } else if (shouldAddCurrentMatchSearchHighlight(pattern, showHighlights, initialOffset)) {
// nohlsearch + incsearch. Even though search highlights are disabled, we still show a highlight (current editor // 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 // 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 return currentEditorCurrentMatchOffset
} }
@ -204,7 +229,7 @@ private fun removeSearchHighlights(editor: Editor) {
*/ */
@Contract("_, _, false -> false; _, null, true -> false") @Contract("_, _, false -> false; _, null, true -> false")
private fun shouldAddAllSearchHighlights(editor: Editor, newPattern: String?, hlSearch: Boolean): Boolean { 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( private fun findClosestMatch(

View File

@ -425,7 +425,7 @@ internal object VimListenerManager {
MotionGroup.fileEditorManagerSelectionChangedCallback(event) MotionGroup.fileEditorManagerSelectionChangedCallback(event)
FileGroup.fileEditorManagerSelectionChangedCallback(event) FileGroup.fileEditorManagerSelectionChangedCallback(event)
VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event) // VimPlugin.getSearch().fileEditorManagerSelectionChangedCallback(event)
IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event) IjVimRedrawService.fileEditorManagerSelectionChangedCallback(event)
VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor) VimLastSelectedEditorTracker.setLastSelectedEditor(event.newEditor)
} }