-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...t/java/org/jetbrains/plugins/ideavim/ex/implementation/variables/HighLightVariableTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright 2003-2024 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 org.jetbrains.plugins.ideavim.ex.implementation.variables | ||
|
||
import org.jetbrains.plugins.ideavim.VimTestCase | ||
import org.junit.jupiter.api.Test | ||
|
||
class HighLightVariableTest : VimTestCase() { | ||
|
||
@Test | ||
fun `test v hlsearch is initially false`() { | ||
configureByText( | ||
""" | ||
|one two one | ||
|${c}three four three | ||
|five six five | ||
""".trimMargin() | ||
) | ||
enterCommand("set hlsearch") | ||
enterCommand("echo v:hlsearch") | ||
assertExOutput("0") | ||
} | ||
|
||
@Test | ||
fun `test v hlsearch is true after successful search`() { | ||
configureByText( | ||
""" | ||
|one two one | ||
|${c}three four three | ||
|five six five | ||
""".trimMargin() | ||
) | ||
enterCommand("set hlsearch") | ||
enterSearch("one") | ||
enterCommand("echo v:hlsearch") | ||
assertExOutput("1") | ||
} | ||
|
||
@Test | ||
fun `test v hlsearch is false after search with no matches`() { | ||
configureByText( | ||
""" | ||
|one two one | ||
|${c}three four three | ||
|five six five | ||
""".trimMargin() | ||
) | ||
enterCommand("set hlsearch") | ||
enterSearch("xyz") | ||
enterCommand("echo v:hlsearch") | ||
assertExOutput("0") | ||
} | ||
|
||
@Test | ||
fun `test v hlsearch is false after nohlsearch command`() { | ||
configureByText( | ||
""" | ||
|one two one | ||
|${c}three four three | ||
|five six five | ||
""".trimMargin() | ||
) | ||
enterCommand("set hlsearch") | ||
enterSearch("one") | ||
enterCommand("nohlsearch") | ||
enterCommand("echo v:hlsearch") | ||
assertExOutput("0") | ||
} | ||
|
||
@Test | ||
fun `test v hlsearch is true after n command reuses previous search`() { | ||
configureByText( | ||
""" | ||
|one two one | ||
|${c}three four three | ||
|five six five | ||
""".trimMargin() | ||
) | ||
enterCommand("set hlsearch") | ||
enterSearch("one") | ||
enterCommand("nohlsearch") | ||
typeText("n") | ||
enterCommand("echo v:hlsearch") | ||
assertExOutput("1") | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/variables/HighLightVariable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2003-2024 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.variables | ||
|
||
import com.maddyhome.idea.vim.api.ExecutionContext | ||
import com.maddyhome.idea.vim.api.VimEditor | ||
import com.maddyhome.idea.vim.api.injector | ||
import com.maddyhome.idea.vim.vimscript.model.VimLContext | ||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType | ||
import com.maddyhome.idea.vim.vimscript.model.datatypes.asVimInt | ||
|
||
class HighLightVariable : Variable { | ||
|
||
override fun evaluate( | ||
name: String, | ||
editor: VimEditor, | ||
context: ExecutionContext, | ||
vimContext: VimLContext, | ||
): VimDataType { | ||
return injector.searchGroup.isSomeTextHighlighted().asVimInt() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters