mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] IJPL-188621 Reset to the console font if non-monospaced font was configured in the terminal settings
Do it only once to fix the issue for all already affected users. GitOrigin-RevId: ff942c8668cd6da3b991d1958b91e6c5ea9e8645
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3b083c8c48
commit
cc109ae609
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.terminal
|
||||
|
||||
import com.intellij.application.options.EditorFontsConstants
|
||||
import com.intellij.ide.ui.UISettingsUtils
|
||||
import com.intellij.ide.util.RunOnceUtil
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
@@ -82,7 +83,10 @@ class TerminalFontSettingsService : AppFontOptions<TerminalFontSettingsState>()
|
||||
|
||||
override fun loadState(state: TerminalFontSettingsState) {
|
||||
columnSpacing = TerminalColumnSpacing.ofFloat(state.COLUMN_SPACING)
|
||||
super.loadState(state)
|
||||
|
||||
if (!resetNonMonospacedFontsOnce(state)) {
|
||||
super.loadState(state)
|
||||
}
|
||||
|
||||
// In the case of RemDev settings are synced from backend to frontend using `loadState` method.
|
||||
// So, notify the listeners on every `loadState` to not miss the change.
|
||||
@@ -108,6 +112,27 @@ class TerminalFontSettingsService : AppFontOptions<TerminalFontSettingsState>()
|
||||
return currentScheme.consoleFontPreferences
|
||||
}
|
||||
|
||||
/**
|
||||
* Because of initial misconfiguration of the settings (IJPL-188621), non-monospaced fonts may be stored in the [storedState].
|
||||
* This logic is intended to reset the font to the default value (from console settings) in this case.
|
||||
* This reset will be performed only once, further calls will do nothing.
|
||||
*
|
||||
* @return whether reset was performed during this call.
|
||||
*/
|
||||
fun resetNonMonospacedFontsOnce(storedState: TerminalFontSettingsState): Boolean {
|
||||
return RunOnceUtil.runOnceForApp("TerminalFontSettingsService.fixStoredNonMonospacedFonts") {
|
||||
val adjustedState = if (!FontFamilyService.isMonospaced(storedState.FONT_FAMILY)) {
|
||||
val newState = TerminalFontSettingsState(getConsoleFontPreferences())
|
||||
newState.FONT_SIZE_2D = storedState.FONT_SIZE_2D
|
||||
newState.LINE_SPACING = storedState.LINE_SPACING
|
||||
newState
|
||||
}
|
||||
else storedState
|
||||
|
||||
super.loadState(adjustedState)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fireListeners() {
|
||||
for (listener in listeners) {
|
||||
listener.fontSettingsChanged()
|
||||
|
||||
Reference in New Issue
Block a user