diff --git a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewContentVersionChecker.kt b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewContentVersionChecker.kt index 49183fbfe90a..b527ed28c3ea 100644 --- a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewContentVersionChecker.kt +++ b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewContentVersionChecker.kt @@ -45,8 +45,8 @@ internal class WhatsNewContentVersionChecker { storedVersion: WhatsNewContent.ContentVersion, newVersion: WhatsNewContent.ContentVersion): Boolean { if (storedVersion.hash.nullize() != null && newVersion.hash.nullize() != null) { - // If both versions have hashes, then show any new content. - return storedVersion.hash != newVersion.hash + // If both versions have hashes, then show any new content (i.e., hashes are different and the version is new). + return storedVersion.hash != newVersion.hash && newVersion >= storedVersion } // At least one of the versions doesn't have a hash: compare them by versions directly, preferring the newest. diff --git a/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewContentVersionCheckerTest.kt b/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewContentVersionCheckerTest.kt index 979d2a31037d..bbefa367a09c 100644 --- a/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewContentVersionCheckerTest.kt +++ b/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewContentVersionCheckerTest.kt @@ -33,7 +33,7 @@ class WhatsNewContentVersionCheckerTest { } @Test - fun `Comparison by two hashes just compares hashes and ignores versions`() { + fun `Comparison by two hashes just compares hashes and ignores versions if the stored is older`() { var version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123") var version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123") assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2)) @@ -44,6 +44,19 @@ class WhatsNewContentVersionCheckerTest { version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, "1231234") version2 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123") - assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2)) + assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2)) + } + + @Test + fun `Comparison with future version`() { + var storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123") + var newVersion = WhatsNewContent.ContentVersion("2020", "8.1", null, "321321") + // On the one hand, the current content differs from the stored. On the other hand, the one stored is *newer*. + assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion)) + + storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123") + newVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "321321") + // Hash-only change ⇒ show the page. + assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion)) } } \ No newline at end of file