Skip to content

Commit

Permalink
Fix set command tests
Browse files Browse the repository at this point in the history
Also hides more feature flags and diagnostic settings from users and unit tests. Shows them when in internal mode.
  • Loading branch information
citizenmatt authored and AlexPl292 committed Feb 23, 2024
1 parent d6cd92e commit f439474
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 106 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/maddyhome/idea/vim/group/IjOptionProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.maddyhome.idea.vim.options.OptionAccessScope
*/
@Suppress("SpellCheckingInspection")
public open class GlobalIjOptions(scope: OptionAccessScope) : OptionsPropertiesBase(scope) {
public var closenotebooks: Boolean by optionProperty(IjOptions.closenotebooks)
public var ide: String by optionProperty(IjOptions.ide)
public var ideamarks: Boolean by optionProperty(IjOptions.ideamarks)
public var ideastatusicon: String by optionProperty(IjOptions.ideastatusicon)
Expand All @@ -29,15 +28,16 @@ public open class GlobalIjOptions(scope: OptionAccessScope) : OptionsPropertiesB
public val lookupkeys: StringListOptionValue by optionProperty(IjOptions.lookupkeys)
public var trackactionids: Boolean by optionProperty(IjOptions.trackactionids)
public var visualdelay: Int by optionProperty(IjOptions.visualdelay)
public var showmodewidget: Boolean by optionProperty(IjOptions.showmodewidget)

// Temporary options to control work-in-progress behaviour
public var closenotebooks: Boolean by optionProperty(IjOptions.closenotebooks)
public var commandOrMotionAnnotation: Boolean by optionProperty(IjOptions.commandOrMotionAnnotation)
public var exCommandAnnotation: Boolean by optionProperty(IjOptions.exCommandAnnotation)
public var oldundo: Boolean by optionProperty(IjOptions.oldundo)
public var showmodewidget: Boolean by optionProperty(IjOptions.showmodewidget)
public var unifyjumps: Boolean by optionProperty(IjOptions.unifyjumps)
public var exCommandAnnotation: Boolean by optionProperty(IjOptions.exCommandAnnotation)
public var vimscriptFunctionAnnotation: Boolean by optionProperty(IjOptions.vimscriptFunctionAnnotation)
public var commandOrMotionAnnotation: Boolean by optionProperty(IjOptions.commandOrMotionAnnotation)
public var useNewRegex: Boolean by optionProperty(IjOptions.useNewRegex)
public var vimscriptFunctionAnnotation: Boolean by optionProperty(IjOptions.vimscriptFunctionAnnotation)
}

/**
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/maddyhome/idea/vim/group/IjOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public object IjOptions {
Options.overrideDefaultValue(Options.clipboard, VimString("ideaput,autoselect,exclude:cons\\|linux"))
}

public val closenotebooks: ToggleOption = addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true))
public val exCommandAnnotation: ToggleOption = addOption(ToggleOption("excommandannotation", GLOBAL, "excommandannotation", true))
public val ide: StringOption = addOption(
StringOption("ide", GLOBAL, "ide", ApplicationNamesInfo.getInstance().fullProductNameWithEdition)
)
Expand Down Expand Up @@ -81,15 +79,19 @@ public object IjOptions {
"<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>")
)
public val trackactionids: ToggleOption = addOption(ToggleOption("trackactionids", GLOBAL, "tai", false))
public val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true))
public val visualdelay: UnsignedNumberOption = addOption(UnsignedNumberOption("visualdelay", GLOBAL, "visualdelay", 100))
public val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isTemporary = true))
public val vimscriptFunctionAnnotation: ToggleOption = addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isTemporary = true))
public val commandOrMotionAnnotation: ToggleOption = addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isTemporary = true))
public val showmodewidget: ToggleOption = addOption(ToggleOption("showmodewidget", GLOBAL, "showmodewidget", false, isTemporary = true))
public val useNewRegex: ToggleOption = addOption(ToggleOption("usenewregex", GLOBAL, "usenewregex", true, isTemporary = true))

// Temporary feature flags during development, not really intended for external use
public val closenotebooks: ToggleOption = addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true, isHidden = true))
public val commandOrMotionAnnotation: ToggleOption = addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isHidden = true))
public val exCommandAnnotation: ToggleOption = addOption(ToggleOption("excommandannotation", GLOBAL, "excommandannotation", true, isHidden = true))
public val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isHidden = true))
public val showmodewidget: ToggleOption = addOption(ToggleOption("showmodewidget", GLOBAL, "showmodewidget", false, isHidden = true))
public val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true, isHidden = true))
public val useNewRegex: ToggleOption = addOption(ToggleOption("usenewregex", GLOBAL, "usenewregex", true, isHidden = true))
public val vimscriptFunctionAnnotation: ToggleOption = addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isHidden = true))

// This needs to be Option<out VimDataType> so that it can work with derived option types, such as NumberOption, which
// derives from Option<VimInt>
private fun <T : Option<out VimDataType>> addOption(option: T) = option.also { Options.addOption(option) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ internal class IjVimApplication : VimApplicationBase() {
return ApplicationManager.getApplication().isUnitTestMode
}

override fun isInternal(): Boolean {
return ApplicationManager.getApplication().isInternal
}

override fun postKey(stroke: KeyStroke, editor: VimEditor) {
val component: Component = SwingUtilities.getAncestorOfClass(Window::class.java, editor.ij.component)
val event = createKeyEvent(stroke, component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set",
"""
|--- Options ---
| ideastrictmode number relativenumber
| number relativenumber
|
""".trimMargin())
}
Expand All @@ -164,22 +164,20 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set all",
"""
|--- Options ---
|noargtextobj ideawrite=all scrolljump=1 notextobj-entire
| closenotebooks noignorecase scrolloff=0 notextobj-indent
|nocommentary noincsearch selectmode= timeout
|nodigraph nomatchit shellcmdflag=-x timeoutlen=1000
|noexchange maxmapdepth=20 shellxescape=@ notrackactionids
|nogdefault more shellxquote={ undolevels=1000
|nohighlightedyank nomultiple-cursors showcmd unifyjumps
| history=50 noNERDTree showmode virtualedit=
|nohlsearch nrformats=hex sidescroll=0 novisualbell
|noideaglobalmode nonumber sidescrolloff=0 visualdelay=100
|noideajoin octopushandler nosmartcase whichwrap=b,s
| ideamarks operatorfunc= nosneak wrapscan
| ideastrictmode norelativenumber startofline
|noideatracetime scroll=0 nosurround
|noargtextobj noincsearch selectmode= notextobj-indent
|nocommentary nomatchit shellcmdflag=-x timeout
|nodigraph maxmapdepth=20 shellxescape=@ timeoutlen=1000
|noexchange more shellxquote={ notrackactionids
|nogdefault nomultiple-cursors showcmd undolevels=1000
|nohighlightedyank noNERDTree showmode virtualedit=
| history=50 nrformats=hex sidescroll=0 novisualbell
|nohlsearch nonumber sidescrolloff=0 visualdelay=100
|noideaglobalmode operatorfunc= nosmartcase whichwrap=b,s
|noideajoin norelativenumber nosneak wrapscan
| ideamarks scroll=0 startofline
| ideawrite=all scrolljump=1 nosurround
|noignorecase scrolloff=0 notextobj-entire
| clipboard=ideaput,autoselect,exclude:cons\|linux
| excommandannotation
| guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
| ide=IntelliJ IDEA Community Edition
|noideacopypreprocess
Expand Down Expand Up @@ -213,7 +211,6 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set!",
"""
|--- Options ---
| ideastrictmode
| number
| relativenumber
|""".trimMargin()
Expand All @@ -227,11 +224,9 @@ class SetCommandTest : VimTestCase() {
|--- Options ---
|noargtextobj
| clipboard=ideaput,autoselect,exclude:cons\|linux
| closenotebooks
|nocommentary
|nodigraph
|noexchange
| excommandannotation
|nogdefault
| guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
|nohighlightedyank
Expand All @@ -244,8 +239,6 @@ class SetCommandTest : VimTestCase() {
| ideamarks
| idearefactormode=select
| ideastatusicon=enabled
| ideastrictmode
|noideatracetime
| ideavimsupport=dialog
| ideawrite=all
|noignorecase
Expand All @@ -261,7 +254,6 @@ class SetCommandTest : VimTestCase() {
|noNERDTree
| nrformats=hex
|nonumber
| octopushandler
| operatorfunc=
|norelativenumber
|noReplaceWithRegister
Expand All @@ -288,7 +280,6 @@ class SetCommandTest : VimTestCase() {
| timeoutlen=1000
|notrackactionids
| undolevels=1000
| unifyjumps
|novim-paragraph-motion
| viminfo='100,<50,s10,h
| virtualedit=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ class SetglobalCommandTest : VimTestCase() {
fun `test show all modified global option values`() {
assertCommandOutput("setglobal", """
|--- Global option values ---
| ideastrictmode
|""".trimMargin()
)
}
Expand All @@ -338,8 +337,7 @@ class SetglobalCommandTest : VimTestCase() {
enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setglobal", """
|--- Global option values ---
| ideastrictmode relativenumber sidescrolloff=10
| number scrolloff=10
| number relativenumber scrolloff=10 sidescrolloff=10
| nrformats=alpha,hex,octal
|""".trimMargin()
)
Expand All @@ -350,22 +348,20 @@ class SetglobalCommandTest : VimTestCase() {
setOsSpecificOptionsToSafeValues()
assertCommandOutput("setglobal all", """
|--- Global option values ---
|noargtextobj ideawrite=all scrolljump=1 notextobj-entire
| closenotebooks noignorecase scrolloff=0 notextobj-indent
|nocommentary noincsearch selectmode= timeout
|nodigraph nomatchit shellcmdflag=-x timeoutlen=1000
|noexchange maxmapdepth=20 shellxescape=@ notrackactionids
|nogdefault more shellxquote={ undolevels=1000
|nohighlightedyank nomultiple-cursors showcmd unifyjumps
| history=50 noNERDTree showmode virtualedit=
|nohlsearch nrformats=hex sidescroll=0 novisualbell
|noideaglobalmode nonumber sidescrolloff=0 visualdelay=100
|noideajoin octopushandler nosmartcase whichwrap=b,s
| ideamarks operatorfunc= nosneak wrapscan
| ideastrictmode norelativenumber startofline
|noideatracetime scroll=0 nosurround
|noargtextobj noincsearch selectmode= notextobj-indent
|nocommentary nomatchit shellcmdflag=-x timeout
|nodigraph maxmapdepth=20 shellxescape=@ timeoutlen=1000
|noexchange more shellxquote={ notrackactionids
|nogdefault nomultiple-cursors showcmd undolevels=1000
|nohighlightedyank noNERDTree showmode virtualedit=
| history=50 nrformats=hex sidescroll=0 novisualbell
|nohlsearch nonumber sidescrolloff=0 visualdelay=100
|noideaglobalmode operatorfunc= nosmartcase whichwrap=b,s
|noideajoin norelativenumber nosneak wrapscan
| ideamarks scroll=0 startofline
| ideawrite=all scrolljump=1 nosurround
|noignorecase scrolloff=0 notextobj-entire
| clipboard=ideaput,autoselect,exclude:cons\|linux
| excommandannotation
| guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
| ide=IntelliJ IDEA Community Edition
|noideacopypreprocess
Expand Down Expand Up @@ -397,7 +393,20 @@ class SetglobalCommandTest : VimTestCase() {
fun `test show all modified global option values in single column`() {
assertCommandOutput("setglobal!", """
|--- Global option values ---
| ideastrictmode
|""".trimMargin()
)
}

@Test
fun `test show all modified global option values in single column 2`() {
enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setglobal!", """
|--- Global option values ---
| nrformats=alpha,hex,octal
| number
| relativenumber
| scrolloff=10
| sidescrolloff=10
|""".trimMargin()
)
}
Expand All @@ -409,11 +418,9 @@ class SetglobalCommandTest : VimTestCase() {
|--- Global option values ---
|noargtextobj
| clipboard=ideaput,autoselect,exclude:cons\|linux
| closenotebooks
|nocommentary
|nodigraph
|noexchange
| excommandannotation
|nogdefault
| guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
|nohighlightedyank
Expand All @@ -426,8 +433,6 @@ class SetglobalCommandTest : VimTestCase() {
| ideamarks
| idearefactormode=select
| ideastatusicon=enabled
| ideastrictmode
|noideatracetime
| ideavimsupport=dialog
| ideawrite=all
|noignorecase
Expand All @@ -443,7 +448,6 @@ class SetglobalCommandTest : VimTestCase() {
|noNERDTree
| nrformats=hex
|nonumber
| octopushandler
| operatorfunc=
|norelativenumber
|noReplaceWithRegister
Expand All @@ -470,7 +474,6 @@ class SetglobalCommandTest : VimTestCase() {
| timeoutlen=1000
|notrackactionids
| undolevels=1000
| unifyjumps
|novim-paragraph-motion
| viminfo='100,<50,s10,h
| virtualedit=
Expand Down
Loading

0 comments on commit f439474

Please sign in to comment.