mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-04-19 10:15:44 +02:00
Compare commits
21 Commits
7c7e7728f2
...
0937234558
Author | SHA1 | Date | |
---|---|---|---|
0937234558 | |||
4e1d7d4228 | |||
b5f7393e45 | |||
522fee294f | |||
300735a6da | |||
8d4f0d838f | |||
325a655dbf | |||
85da8f7b8d | |||
bd2e1e5888 | |||
34a1845cc2 | |||
d02cc5960d | |||
285053e530 | |||
f9ea683c9a | |||
d3f736a69e | |||
13bfc98ddf | |||
05fd29c0ec | |||
c8512a2e59 | |||
cc1437092f | |||
6d83464cd7 | |||
d5be9cc8b6 | |||
6026b304c2 |
@ -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", "243.21565.122")
|
plugin("com.intellij.classic.ui", "242.20224.159")
|
||||||
|
|
||||||
bundledPlugins("org.jetbrains.plugins.terminal", "com.intellij.modules.json")
|
bundledPlugins("org.jetbrains.plugins.terminal", "com.intellij.modules.json")
|
||||||
}
|
}
|
||||||
|
@ -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
|
ideaVersion=2024.3.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-44
|
version=chylex-43
|
||||||
javaVersion=21
|
javaVersion=21
|
||||||
remoteRobotVersion=0.11.23
|
remoteRobotVersion=0.11.23
|
||||||
antlrVersion=4.10.1
|
antlrVersion=4.10.1
|
||||||
|
@ -17,7 +17,6 @@ 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
|
||||||
@ -31,7 +30,6 @@ 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?,
|
||||||
@ -86,12 +84,6 @@ 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
|
||||||
*/
|
*/
|
||||||
@ -133,28 +125,17 @@ 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 isSearching = injector.commandLine.getActiveCommandLine() != null
|
|
||||||
application.invokeLater {
|
|
||||||
val vimEditor = editor.vim
|
val vimEditor = editor.vim
|
||||||
val editorLastLine = vimEditor.lineCount() - 1
|
val editorLastLine = vimEditor.lineCount() - 1
|
||||||
val searchStartLine = searchRange?.startLine ?: 0
|
val searchStartLine = searchRange?.startLine ?: 0
|
||||||
val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine)
|
val searchEndLine = (searchRange?.endLine ?: -1).coerceAtMost(editorLastLine)
|
||||||
if (searchStartLine <= 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 =
|
val results =
|
||||||
injector.searchHelper.findAll(
|
injector.searchHelper.findAll(
|
||||||
vimEditor,
|
vimEditor,
|
||||||
pattern,
|
pattern,
|
||||||
searchStartLine.coerceAtLeast(visibleStartLine),
|
searchStartLine,
|
||||||
searchEndLine.coerceAtMost(visibleEndLine),
|
searchEndLine,
|
||||||
shouldIgnoreCase(pattern, shouldIgnoreSmartCase)
|
shouldIgnoreCase(pattern, shouldIgnoreSmartCase)
|
||||||
)
|
)
|
||||||
if (results.isNotEmpty()) {
|
if (results.isNotEmpty()) {
|
||||||
@ -162,14 +143,9 @@ private fun updateSearchHighlights(
|
|||||||
currentMatchOffset = findClosestMatch(results, initialOffset, count1, forwards)
|
currentMatchOffset = findClosestMatch(results, initialOffset, count1, forwards)
|
||||||
}
|
}
|
||||||
highlightSearchResults(editor, pattern, results, currentMatchOffset)
|
highlightSearchResults(editor, pattern, results, currentMatchOffset)
|
||||||
if (!isSearching) {
|
|
||||||
removeHighlightsEditors.add(editor)
|
|
||||||
removeHighlightsTimer.restart()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
@ -203,7 +179,6 @@ private fun updateSearchHighlights(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeHighlightsTimer.restart()
|
|
||||||
return currentEditorCurrentMatchOffset
|
return currentEditorCurrentMatchOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +204,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 != ""
|
return hlSearch && newPattern != null && newPattern != editor.vimLastSearch && newPattern != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findClosestMatch(
|
private fun findClosestMatch(
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user