Having a difficult time using `PersistentStateComp...
# intellij-plugins
b
Having a difficult time using
PersistentStateComponent
. Nothing seems to be calling
loadState()
. Any ideas what I'm doing wrong? https://github.com/johnlindquist/AceJump/blob/master/src/main/kotlin/com/johnlindquist/acejump/config/AceConfig.kt
y
loadState() will only be called if there are non-default settings persisted in the .xml file. also classes like this one really need to be services, not application components
b
changed
AceConfig
to be a service from the plugin manifest and ensured that the settings are non-default. It remembers settings between opening the settings page, but once the IDE is restarted, it forgets all settings. Also I'm not seeing any file called "AceJump.xml" as declared in the Storage annotation
y
I don’t think PersistentStateComponent actually supports serializing Color values
b
Oh, that makes sense! But the function
loadState()
is never called, I debugged it.
Settings
also contains a collection of chars which is not persisted. I think it may have something to do with the way Kotlin instantiates objects. Also I'm mixing
Configurable
and
PersistentStateComponent
, could that be a problem?
y
loadState() will only be called if there is some state that has been successfully persisted
b
Shouldn't
PersistentStateComponent
be able to persist changes to
allowedChars
? I can verify that those changes are being stored inside
AceConfig.settings
as long as the IDE is open