Add ExpandCollapseToggleAction to IdeActions so it can be used by plugins like IdeaVim to support 'za' vim motion

closes https://github.com/JetBrains/intellij-community/pull/2825

GitOrigin-RevId: 27026dda3b9355a652c8ad5d6cb58efdac27ced6
This commit is contained in:
The1xDeveloper
2024-08-15 20:00:17 -04:00
committed by intellij-monorepo-bot
parent ab9cb4af64
commit dc4b3eccd4
3 changed files with 23 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.impl;
import com.intellij.codeInsight.CodeInsightSettings;
@@ -95,6 +96,26 @@ public class JavaFoldingTest extends JavaFoldingTestCase {
assertEquals(text.indexOf("}", text.indexOf("i++")), myFixture.getEditor().getCaretModel().getOffset());
}
public void testExpandCollapseRegionTogglesFold() {
String text = """
class Test {
void test(int i) {
if (i > 1) {
<caret>i++;
}
}
}
""";
configure(text);
assertEquals(2, getExpandedFoldRegionsCount());
myFixture.performEditorAction(IdeActions.ACTION_EXPAND_COLLAPSE_TOGGLE_REGION);
assertEquals(1, getExpandedFoldRegionsCount());
myFixture.performEditorAction(IdeActions.ACTION_EXPAND_COLLAPSE_TOGGLE_REGION);
assertEquals(2, getExpandedFoldRegionsCount());
}
public void testFoldGroup() {
// Implied by IDEA-79420
myFoldingSettings.setCollapseLambdas(true);

View File

@@ -1204,6 +1204,7 @@ com.intellij.openapi.actionSystem.IdeActions
- sf:ACTION_EXPAND_ALL:java.lang.String
- sf:ACTION_EXPAND_ALL_REGIONS:java.lang.String
- sf:ACTION_EXPAND_ALL_TO_LEVEL_1:java.lang.String
- sf:ACTION_EXPAND_COLLAPSE_TOGGLE_REGION:java.lang.String
- sf:ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB:java.lang.String
- sf:ACTION_EXPAND_LIVE_TEMPLATE_CUSTOM:java.lang.String
- sf:ACTION_EXPAND_REGION:java.lang.String

View File

@@ -205,6 +205,7 @@ public interface IdeActions {
String ACTION_COLLAPSE_REGION_RECURSIVELY = "CollapseRegionRecursively";
String ACTION_EXPAND_TO_LEVEL_1 = "ExpandToLevel1";
String ACTION_EXPAND_ALL_TO_LEVEL_1 = "ExpandAllToLevel1";
String ACTION_EXPAND_COLLAPSE_TOGGLE_REGION = "ExpandCollapseToggleAction";
String ACTION_NEW_HORIZONTAL_TAB_GROUP = "NewHorizontalTabGroup";
String ACTION_NEW_VERTICAL_TAB_GROUP = "NewVerticalTabGroup";