-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addDefault doesn't work since 1.8 if file contains only defaults #64
Labels
Comments
Having the same Issue. |
Yes, it is a bug of version 1.8. It happens only when there are no keys set (only defaults, without any use of See the following example. I added a set call to your example. val yamlFile = YamlFile("test.yml")
yamlFile.createOrLoad()
yamlFile.addDefault("default", "test")
yamlFile.set("key", 0)
yamlFile.save()
default: test
key: 0 |
Carleslc
changed the title
addDefault doesn't work since 1.8
addDefault doesn't work since 1.8 if file contains only defaults
Aug 1, 2022
Reopen until the 1.8.1 release |
Workaround for 1.8: fun addDefault(yamlFile: YamlFile, path: String, value: Any) {
if (!yamlFile.isSet(path)) {
yamlFile.set(path, value)
}
yamlFile.addDefault(path, value)
}
fun main() {
val yamlFile = YamlFile("test.yml")
yamlFile.createOrLoad()
addDefault(yamlFile, "default", "test")
yamlFile.save()
} default: test |
Fixed in 1.8.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed that since the 1.8 update that addDefault doesn't work any more since the test.yml is empty after being created and saved.
I was able to recreate this in a test project which I uploaded to github: https://github.com/ChimpGamer/SimpleYamlBug/blob/main/src/main/kotlin/nl/chimpgamer/simpleyamlbug/Main.kt
Am I missing something or is it really a bug?
The text was updated successfully, but these errors were encountered: