IJPL-157227 IDE is localized after Settings Sync between 2024.1 and 2024.2 if language plugins had updates

GitOrigin-RevId: 2b596270b6052ec178ad026d3dc3b64a3b25c46e
This commit is contained in:
Sergey Pak
2024-06-27 20:49:55 +00:00
committed by intellij-monorepo-bot
parent b96a47cd24
commit bbb830453c
2 changed files with 52 additions and 3 deletions
@@ -26,6 +26,8 @@ internal class SettingsSyncPluginManager(private val cs: CoroutineScope) : Dispo
private val pluginEnabledStateListener = PluginEnabledStateListener()
private val LOCK = Object()
private val PLUGIN_EXCEPTIONS = setOf("com.intellij.ja", "com.intellij.ko", "com.intellij.zh")
internal var state = SettingsSyncPluginsState(emptyMap())
private set
@@ -70,11 +72,13 @@ internal class SettingsSyncPluginManager(private val cs: CoroutineScope) : Dispo
for (plugin in currentIdePlugins) {
val id = plugin.pluginId
if (PluginManagerProxy.getInstance().isEssential(id)
|| PluginManagerProxy.getInstance().isIncompatible(plugin)) {
if (!isPluginSynceable(id) || PluginManagerProxy.getInstance().isIncompatible(plugin)) {
// don't change state of essential plugin (it will be enabled in the current IDE anyway)
// also, don't take into account incompatible plugins (makes no sense to deal with them)
// other IDEs will manage such plugins themselves
// also don't touch localization plugins as they become bundled in 242 and might cause issues:
// see https://youtrack.jetbrains.com/issue/IJPL-157227/IDE-is-localized-after-Settings-Sync-between-2024.1-and-2024.2-if-language-plugins-had-updates
}
else if (shouldSaveState(plugin)) {
newPlugins[id] = getPluginData(plugin)
@@ -90,6 +94,9 @@ internal class SettingsSyncPluginManager(private val cs: CoroutineScope) : Dispo
}
}
private fun isPluginSynceable(pluginId: PluginId): Boolean =
!(PluginManagerProxy.getInstance().isEssential(pluginId) || PLUGIN_EXCEPTIONS.contains(pluginId.idString))
private fun firePluginsStateChangeEvent(pluginsState: SettingsSyncPluginsState) {
val snapshot = SettingsSnapshot(SettingsSnapshot.MetaInfo(Instant.now(), getLocalApplicationInfo()),
emptySet(), pluginsState, emptyMap(), emptySet())
@@ -257,7 +264,7 @@ internal class SettingsSyncPluginManager(private val cs: CoroutineScope) : Dispo
isPluginSyncEnabled(plugin.pluginId, plugin.isBundled, SettingsSyncPluginCategoryFinder.getPluginCategory(plugin))
private fun isPluginSyncEnabled(id: PluginId, isBundled: Boolean, category: SettingsCategory): Boolean {
if (PluginManagerProxy.getInstance().isEssential(id))
if (!isPluginSynceable(id))
return false
val settings = SettingsSyncSettings.getInstance()
return settings.isCategoryEnabled(category) &&
@@ -424,6 +424,48 @@ class SettingsSyncPluginManagerTest : BasePluginManagerTest() {
restart_required_base(true, true, false)
}
@Test
@TestFor(issues = ["IJPL-157227"])
fun `don't touch localization plugins state in 242+`() {
val localization_ja = TestPluginDescriptor(
"com.intellij.ja",
listOf(TestPluginDependency("com.intellij.modules.platform", isOptional = false)),
bundled = true
)
val localization_kr = TestPluginDescriptor(
"com.intellij.kr",
listOf(TestPluginDependency("com.intellij.modules.platform", isOptional = false)),
bundled = false
)
val localization_zh = TestPluginDescriptor(
"com.intellij.zh",
listOf(TestPluginDependency("com.intellij.modules.platform", isOptional = false)),
bundled = false
)
testPluginManager.addPluginDescriptors(localization_ja, localization_kr, localization_zh, git4idea, cvsOutdated.withEnabled(false))
val pushedState = state {
localization_ja(enabled = true)
localization_kr(enabled = true)
git4idea(enabled = true)
cvsOutdated(enabled = false)
}
pushToIdeAndWait(pushedState)
assertIdeState {
git4idea(enabled = true)
cvsOutdated(enabled = false)
localization_ja(enabled = true)
localization_kr(enabled = true)
localization_zh(enabled = true)
}
assertPluginManagerState {
cvsOutdated(enabled = false) // remains the same as it's incompatible
localization_ja(enabled = true)
localization_kr(enabled = true)
}
}
private fun restart_required_base(installedBefore: Boolean, enabledBefore: Boolean, enabledInPush: Boolean) = runTest {
val restartRequiredRef = AtomicReference<RestartReason>()
SettingsSyncEvents.getInstance().addListener(object : SettingsSyncEventListener {