mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-28 00:34:02 +02:00
Update mode widget text for Select pending
This commit is contained in:
parent
63b3af3f65
commit
a28416dd9f
src
main/java/com/maddyhome/idea/vim/ui/widgets/mode
test/java/org/jetbrains/plugins/ideavim/command
@ -35,10 +35,8 @@ class VimModeWidget(val project: Project) : CustomStatusBarWidget, VimStatusBarW
|
|||||||
companion object {
|
companion object {
|
||||||
private const val INSERT = "INSERT"
|
private const val INSERT = "INSERT"
|
||||||
private const val NORMAL = "NORMAL"
|
private const val NORMAL = "NORMAL"
|
||||||
private const val INSERT_NORMAL = "(insert)"
|
|
||||||
private const val INSERT_PENDING_PREFIX = "(insert) "
|
private const val INSERT_PENDING_PREFIX = "(insert) "
|
||||||
private const val REPLACE = "REPLACE"
|
private const val REPLACE = "REPLACE"
|
||||||
private const val REPLACE_NORMAL = "(replace)"
|
|
||||||
private const val REPLACE_PENDING_PREFIX = "(replace) "
|
private const val REPLACE_PENDING_PREFIX = "(replace) "
|
||||||
private const val COMMAND = "COMMAND"
|
private const val COMMAND = "COMMAND"
|
||||||
private const val VISUAL = "VISUAL"
|
private const val VISUAL = "VISUAL"
|
||||||
@ -47,6 +45,7 @@ class VimModeWidget(val project: Project) : CustomStatusBarWidget, VimStatusBarW
|
|||||||
private const val SELECT = "SELECT"
|
private const val SELECT = "SELECT"
|
||||||
private const val SELECT_LINE = "S-LINE"
|
private const val SELECT_LINE = "S-LINE"
|
||||||
private const val SELECT_BLOCK = "S-BLOCK"
|
private const val SELECT_BLOCK = "S-BLOCK"
|
||||||
|
private const val SELECT_PENDING_PREFIX = "(select) "
|
||||||
|
|
||||||
fun getModeText(mode: Mode?): String? {
|
fun getModeText(mode: Mode?): String? {
|
||||||
return when (mode) {
|
return when (mode) {
|
||||||
@ -60,16 +59,30 @@ class VimModeWidget(val project: Project) : CustomStatusBarWidget, VimStatusBarW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the text to show in Normal mode
|
||||||
|
*
|
||||||
|
* Vim doesn't show any text for Normal, but that doesn't work for IdeaVim's status widget. We also show "NORMAL"
|
||||||
|
* when Insert or Replace is pending. I.e. "(insert) NORMAL" and "(replace) NORMAL". Vim only shows the pending mode
|
||||||
|
*/
|
||||||
private fun getNormalModeText(mode: Mode.NORMAL) = when {
|
private fun getNormalModeText(mode: Mode.NORMAL) = when {
|
||||||
mode.isInsertPending -> INSERT_NORMAL
|
mode.isInsertPending -> INSERT_PENDING_PREFIX + NORMAL
|
||||||
mode.isReplacePending -> REPLACE_NORMAL
|
mode.isReplacePending -> REPLACE_PENDING_PREFIX + NORMAL
|
||||||
else -> NORMAL
|
else -> NORMAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the text to show in Visual mode
|
||||||
|
*
|
||||||
|
* IdeaVim shows the Insert and Replace pending modes, but we also show Select pending - "(select) VISUAL". Vim
|
||||||
|
* doesn't show this, but IdeaVim's status widget isn't like Vim's status bar, and this addition keeps things a
|
||||||
|
* little more consistent.
|
||||||
|
*/
|
||||||
private fun getVisualModeText(mode: Mode.VISUAL): String {
|
private fun getVisualModeText(mode: Mode.VISUAL): String {
|
||||||
val prefix = when {
|
val prefix = when {
|
||||||
mode.isInsertPending -> INSERT_PENDING_PREFIX
|
mode.isInsertPending -> INSERT_PENDING_PREFIX
|
||||||
mode.isReplacePending -> REPLACE_PENDING_PREFIX
|
mode.isReplacePending -> REPLACE_PENDING_PREFIX
|
||||||
|
mode.isSelectPending -> SELECT_PENDING_PREFIX
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
return prefix + when (mode.selectionType) {
|
return prefix + when (mode.selectionType) {
|
||||||
|
@ -94,7 +94,7 @@ class VimShowModeTest : VimTestCase() {
|
|||||||
configureByText("123")
|
configureByText("123")
|
||||||
typeText("i<C-O>")
|
typeText("i<C-O>")
|
||||||
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
||||||
assertEquals("(insert)", statusString)
|
assertEquals("(insert) NORMAL", statusString)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -110,7 +110,7 @@ class VimShowModeTest : VimTestCase() {
|
|||||||
configureByText("123")
|
configureByText("123")
|
||||||
typeText("R<C-O>")
|
typeText("R<C-O>")
|
||||||
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
||||||
assertEquals("(replace)", statusString)
|
assertEquals("(replace) NORMAL", statusString)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -193,4 +193,13 @@ class VimShowModeTest : VimTestCase() {
|
|||||||
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
||||||
assertEquals("(insert) S-LINE", statusString)
|
assertEquals("(insert) S-LINE", statusString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test status string in Visual with Select pending`() {
|
||||||
|
configureByText("123")
|
||||||
|
enterCommand("set selectmode=key keymodel=startsel")
|
||||||
|
typeText("<S-Right><C-O>")
|
||||||
|
val statusString = VimModeWidget.getModeText(fixture.editor.vim.mode)
|
||||||
|
assertEquals("(select) VISUAL", statusString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user