File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/main/java/com/maddyhome/idea/vim/group Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1357,10 +1357,22 @@ private class FoldLevelOptionMapper : LocalOptionValueOverride<VimInt> {
13571357 val maxDepth = editor.getMaxFoldDepth()
13581358 val coercedLevel = newValue.value.value.coerceIn(0 , maxDepth + 1 )
13591359
1360- editor.applyFoldLevel(coercedLevel)
1360+ // When a new window opens, setLocalValue is called twice: first from copyLocalToWindowLocalValues,
1361+ // then from initialiseLocalToWindowOptions. We skip applyFoldLevel in both cases to preserve
1362+ // IntelliJ's default fold state. The first call has storedValue=null, and the second has both
1363+ // storedValue and newValue as Default - these conditions define initialization.
1364+ if (! isInitializing(storedValue, newValue)) {
1365+ editor.applyFoldLevel(coercedLevel)
1366+ }
13611367
13621368 return storedValue?.value?.value != coercedLevel
13631369 }
1370+
1371+ private fun isInitializing (
1372+ storedValue : OptionValue <VimInt >? ,
1373+ newValue : OptionValue <VimInt >,
1374+ ): Boolean = storedValue == null ||
1375+ (storedValue is OptionValue .Default && newValue is OptionValue .Default )
13641376}
13651377
13661378
You can’t perform that action at this time.
0 commit comments