1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-04-22 01:15:48 +02:00

Update search register when using f/t

This commit is contained in:
chylex 2024-01-23 13:16:02 +01:00
parent a1639d80b0
commit 9240e82f2d
Signed by: chylex
SSH Key Fingerprint: SHA256:WqM8X/1DDn11LbYM0H5wsqZUjbcKxVsic37L+ERcF4o
3 changed files with 21 additions and 2 deletions
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -76,6 +76,13 @@ sealed class TillCharacterMotion(
)
}
injector.motion.setLastFTCmd(tillCharacterMotionType, argument.character)
val offset = if (!finishBeforeCharacter) ""
else if (direction == Direction.FORWARDS) "s-1"
else "s+1"
injector.searchGroup.setLastSearchState(argument.character.let { if (it == '.') "\\." else it.toString() }, offset, direction)
return res.toMotionOrError()
}
}

View File

@ -206,4 +206,17 @@ interface VimSearchGroup {
* Returns true if any text is selected in the visible editors, false otherwise.
*/
fun isSomeTextHighlighted(): Boolean
/**
* Sets the last search state purely for tests
*
* @param pattern The pattern to save. This is the last search pattern, not the last substitute pattern
* @param patternOffset The pattern offset, e.g. `/{pattern}/{offset}`
* @param direction The direction to search
*/
fun setLastSearchState(
pattern: String,
patternOffset: String,
direction: Direction,
)
}

View File

@ -1425,8 +1425,7 @@ abstract class VimSearchGroupBase : VimSearchGroup {
* @param patternOffset The pattern offset, e.g. `/{pattern}/{offset}`
* @param direction The direction to search
*/
@TestOnly
fun setLastSearchState(
override fun setLastSearchState(
pattern: String,
patternOffset: String,
direction: Direction,