diff --git a/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt index 41fd630be841..5985c0e8c139 100644 --- a/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt +++ b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt @@ -2,15 +2,22 @@ package com.intellij.configurationStore import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PathManager +import com.intellij.openapi.application.ex.PathManagerEx import com.intellij.openapi.application.impl.ApplicationImpl import com.intellij.openapi.components.stateStore +import com.intellij.openapi.util.io.FileUtil import com.intellij.testFramework.ProjectRule +import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.io.delete import org.junit.ClassRule import org.junit.Test +import java.nio.file.Path import java.nio.file.Paths +private val testData: Path + get() = Paths.get(PathManagerEx.getHomePath(DoNotSaveDefaultsTest::class.java), FileUtil.toSystemDependentName("platform/configuration-store-impl/testSrc")) + class DoNotSaveDefaultsTest { companion object { @JvmField @@ -41,7 +48,9 @@ class DoNotSaveDefaultsTest { } println(directory) - println(printDirectoryTree(dirPath)) + val directoryTree = printDirectoryTree(dirPath, setOf("path.macros.xml")) + println(directoryTree) + assertThat(directoryTree).toMatchSnapshot(testData.resolve("DoNotSaveDefaults.snap.txt")) } } diff --git a/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.snap.txt b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.snap.txt new file mode 100644 index 000000000000..a614936fa461 --- /dev/null +++ b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.snap.txt @@ -0,0 +1 @@ +'' diff --git a/platform/configuration-store-impl/testSrc/FileTreePrinter.kt b/platform/configuration-store-impl/testSrc/FileTreePrinter.kt index 3eda50fc3789..6b7fabaf86ed 100644 --- a/platform/configuration-store-impl/testSrc/FileTreePrinter.kt +++ b/platform/configuration-store-impl/testSrc/FileTreePrinter.kt @@ -5,21 +5,27 @@ import com.intellij.util.io.isDirectory import java.nio.file.Path import java.util.* -fun printDirectoryTree(dir: Path): String { +fun printDirectoryTree(dir: Path, excluded: Set = emptySet()): String { val sb = StringBuilder() - printDirectoryTree(dir, 0, sb) + printDirectoryTree(dir, 0, sb, excluded) return sb.toString() } -private fun printDirectoryTree(dir: Path, indent: Int, sb: StringBuilder) { +private fun printDirectoryTree(dir: Path, indent: Int, sb: StringBuilder, excluded: Set) { + val fileList = sortedFileList(dir) ?: return + getIndentString(indent, sb) sb.append("\u251c\u2500\u2500") sb.append(dir.fileName.toString()) sb.append("/") sb.append("\n") - for (file in sortedFileList(dir)) { + for (file in fileList) { + if (excluded.contains(file.fileName.toString())) { + continue + } + if (file.isDirectory()) { - printDirectoryTree(file, indent + 1, sb) + printDirectoryTree(file, indent + 1, sb, excluded) } else { printFile(file, indent + 1, sb) @@ -27,13 +33,13 @@ private fun printDirectoryTree(dir: Path, indent: Int, sb: StringBuilder) { } } -private fun sortedFileList(dir: Path): List { +private fun sortedFileList(dir: Path): List? { return dir.directoryStreamIfExists { val list = ArrayList() it.mapTo(list) { it } list.sort() list - } ?: emptyList() + } } private fun printFile(file: Path, indent: Int, sb: StringBuilder) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java index 15cce3b24847..b028de5db02b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.java @@ -353,9 +353,10 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers @Nullable @Override public State getState() { - if (mySchemeManager.getCurrentScheme() != null) { - String name = mySchemeManager.getCurrentScheme().getName(); - myState.colorScheme = "Default".equals(name) ? null : name; + String currentSchemeName = mySchemeManager.getCurrentSchemeName(); + if (currentSchemeName != null) { + myState.colorScheme = ("Default".equals(currentSchemeName) || (SchemeManager.EDITABLE_COPY_PREFIX + "Default").equals( + currentSchemeName)) ? null : currentSchemeName; } return myState; } diff --git a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/PathAssertEx.kt b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/PathAssertEx.kt index 317055b92919..c0eb3fd0e338 100644 --- a/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/PathAssertEx.kt +++ b/platform/testFramework/extensions/src/com/intellij/testFramework/assertions/PathAssertEx.kt @@ -68,4 +68,10 @@ class StringAssertEx(actual: String?) : AbstractCharSequenceAssert testClass) { + public static String getHomePath(Class testClass) { TestDataLookupStrategy strategy = isLocatedInCommunity() ? TestDataLookupStrategy.COMMUNITY : determineLookupStrategy(testClass); return strategy == TestDataLookupStrategy.COMMUNITY_FROM_ULTIMATE ? getCommunityHomePath() : PathManager.getHomePath(); }