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 committed Feb 5, 2024
1 parent e07f5bb commit b881abf
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 100 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,21 +164,19 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set all",
"""
|--- Options ---
|noargtextobj noideatracetime scroll=0 nosurround
| closenotebooks ideawrite=all scrolljump=1 notextobj-entire
|nocommentary noignorecase scrolloff=0 notextobj-indent
|nodigraph noincsearch selectmode= timeout
|noexchange nomatchit shellcmdflag=-x timeoutlen=1000
|nogdefault maxmapdepth=20 shellxescape=@ notrackactionids
|nohighlightedyank more shellxquote={ undolevels=1000
| history=50 nomultiple-cursors showcmd unifyjumps
|nohlsearch noNERDTree showmode virtualedit=
|noideaglobalmode nrformats=hex sidescroll=0 novisualbell
|noideajoin nonumber sidescrolloff=0 visualdelay=100
| ideamarks operatorfunc= nosmartcase whichwrap=b,s
| ideastrictmode norelativenumber startofline wrapscan
|noargtextobj noignorecase scrolljump=1 nosurround
|nocommentary noincsearch scrolloff=0 notextobj-entire
|nodigraph nomatchit selectmode= notextobj-indent
|noexchange maxmapdepth=20 shellcmdflag=-x timeout
|nogdefault more shellxescape=@ timeoutlen=1000
|nohighlightedyank nomultiple-cursors shellxquote={ notrackactionids
| history=50 noNERDTree showcmd undolevels=1000
|nohlsearch nrformats=hex showmode virtualedit=
|noideaglobalmode nonumber sidescroll=0 novisualbell
|noideajoin operatorfunc= sidescrolloff=0 visualdelay=100
| ideamarks norelativenumber nosmartcase whichwrap=b,s
| ideawrite=all scroll=0 startofline wrapscan
| 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 @@ -212,7 +210,6 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set!",
"""
|--- Options ---
| ideastrictmode
| number
| relativenumber
|""".trimMargin()
Expand All @@ -226,11 +223,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 @@ -243,8 +238,6 @@ class SetCommandTest : VimTestCase() {
| ideamarks
| idearefactormode=select
| ideastatusicon=enabled
| ideastrictmode
|noideatracetime
| ideavimsupport=dialog
| ideawrite=all
|noignorecase
Expand Down Expand Up @@ -285,7 +278,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,21 +348,19 @@ class SetglobalCommandTest : VimTestCase() {
setOsSpecificOptionsToSafeValues()
assertCommandOutput("setglobal all", """
|--- Global option values ---
|noargtextobj noideatracetime scroll=0 nosurround
| closenotebooks ideawrite=all scrolljump=1 notextobj-entire
|nocommentary noignorecase scrolloff=0 notextobj-indent
|nodigraph noincsearch selectmode= timeout
|noexchange nomatchit shellcmdflag=-x timeoutlen=1000
|nogdefault maxmapdepth=20 shellxescape=@ notrackactionids
|nohighlightedyank more shellxquote={ undolevels=1000
| history=50 nomultiple-cursors showcmd unifyjumps
|nohlsearch noNERDTree showmode virtualedit=
|noideaglobalmode nrformats=hex sidescroll=0 novisualbell
|noideajoin nonumber sidescrolloff=0 visualdelay=100
| ideamarks operatorfunc= nosmartcase whichwrap=b,s
| ideastrictmode norelativenumber startofline wrapscan
|noargtextobj noignorecase scrolljump=1 nosurround
|nocommentary noincsearch scrolloff=0 notextobj-entire
|nodigraph nomatchit selectmode= notextobj-indent
|noexchange maxmapdepth=20 shellcmdflag=-x timeout
|nogdefault more shellxescape=@ timeoutlen=1000
|nohighlightedyank nomultiple-cursors shellxquote={ notrackactionids
| history=50 noNERDTree showcmd undolevels=1000
|nohlsearch nrformats=hex showmode virtualedit=
|noideaglobalmode nonumber sidescroll=0 novisualbell
|noideajoin operatorfunc= sidescrolloff=0 visualdelay=100
| ideamarks norelativenumber nosmartcase whichwrap=b,s
| ideawrite=all scroll=0 startofline wrapscan
| 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 @@ -396,7 +392,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 @@ -408,11 +417,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 @@ -425,8 +432,6 @@ class SetglobalCommandTest : VimTestCase() {
| ideamarks
| idearefactormode=select
| ideastatusicon=enabled
| ideastrictmode
|noideatracetime
| ideavimsupport=dialog
| ideawrite=all
|noignorecase
Expand Down Expand Up @@ -467,7 +472,6 @@ class SetglobalCommandTest : 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 @@ -355,8 +355,7 @@ class SetlocalCommandTest : VimTestCase() {
fun `test show all modified local option and unset global-local values`() {
assertCommandOutput("setlocal", """
|--- Local option values ---
|--ideajoin ideastrictmode sidescrolloff=-1
| idearefactormode= scrolloff=-1
|--ideajoin idearefactormode= scrolloff=-1 sidescrolloff=-1
|--ideacopypreprocess
| undolevels=-123456
|""".trimMargin()
Expand All @@ -368,8 +367,8 @@ class SetlocalCommandTest : VimTestCase() {
enterCommand("setlocal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setlocal", """
|--- Local option values ---
|--ideajoin ideastrictmode relativenumber sidescrolloff=10
| idearefactormode= number scrolloff=10
|--ideajoin number scrolloff=10
| idearefactormode= relativenumber sidescrolloff=10
|--ideacopypreprocess
| nrformats=alpha,hex,octal
| undolevels=-123456
Expand All @@ -382,21 +381,19 @@ class SetlocalCommandTest : VimTestCase() {
setOsSpecificOptionsToSafeValues()
assertCommandOutput("setlocal all", """
|--- Local option values ---
|noargtextobj ideastrictmode norelativenumber startofline
| closenotebooks noideatracetime scroll=0 nosurround
|nocommentary ideawrite=all scrolljump=1 notextobj-entire
|nodigraph noignorecase scrolloff=-1 notextobj-indent
|noexchange noincsearch selectmode= timeout
|nogdefault nomatchit shellcmdflag=-x timeoutlen=1000
|nohighlightedyank maxmapdepth=20 shellxescape=@ notrackactionids
| history=50 more shellxquote={ unifyjumps
|nohlsearch nomultiple-cursors showcmd virtualedit=
|noideaglobalmode noNERDTree showmode novisualbell
|--ideajoin nrformats=hex sidescroll=0 visualdelay=100
| ideamarks nonumber sidescrolloff=-1 whichwrap=b,s
| idearefactormode= operatorfunc= nosmartcase wrapscan
|noargtextobj ideawrite=all scroll=0 startofline
|nocommentary noignorecase scrolljump=1 nosurround
|nodigraph noincsearch scrolloff=-1 notextobj-entire
|noexchange nomatchit selectmode= notextobj-indent
|nogdefault maxmapdepth=20 shellcmdflag=-x timeout
|nohighlightedyank more shellxescape=@ timeoutlen=1000
| history=50 nomultiple-cursors shellxquote={ notrackactionids
|nohlsearch noNERDTree showcmd virtualedit=
|noideaglobalmode nrformats=hex showmode novisualbell
|--ideajoin nonumber sidescroll=0 visualdelay=100
| ideamarks operatorfunc= sidescrolloff=-1 whichwrap=b,s
| idearefactormode= norelativenumber nosmartcase wrapscan
| 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
|--ideacopypreprocess
Expand Down Expand Up @@ -431,7 +428,6 @@ class SetlocalCommandTest : VimTestCase() {
|--ideacopypreprocess
|--ideajoin
| idearefactormode=
| ideastrictmode
| scrolloff=-1
| sidescrolloff=-1
| undolevels=-123456
Expand All @@ -446,11 +442,9 @@ class SetlocalCommandTest : VimTestCase() {
|--- Local 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 @@ -463,8 +457,6 @@ class SetlocalCommandTest : VimTestCase() {
| ideamarks
| idearefactormode=
| ideastatusicon=enabled
| ideastrictmode
|noideatracetime
| ideavimsupport=dialog
| ideawrite=all
|noignorecase
Expand Down Expand Up @@ -505,7 +497,6 @@ class SetlocalCommandTest : VimTestCase() {
| timeoutlen=1000
|notrackactionids
| undolevels=-123456
| unifyjumps
|novim-paragraph-motion
| viminfo='100,<50,s10,h
| virtualedit=
Expand Down
Loading

0 comments on commit b881abf

Please sign in to comment.