Skip to content
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

ini Remove method leaves the key behind #47

Closed
ixm7 opened this issue Jun 23, 2021 · 3 comments
Closed

ini Remove method leaves the key behind #47

ixm7 opened this issue Jun 23, 2021 · 3 comments

Comments

@ixm7
Copy link

ixm7 commented Jun 23, 2021

The ini Remove method deletes the key value but leaves the key behind.

Before the call:
[mySection]
myKey="myValue"

After calling gINIFile.Item("mySection").Remove("myKey"):
[mySection]
myKey

Expected behavior is for myKey to be completely removed.

@fluffynuts
Copy link
Owner

Hi @ixm7

This is the first I've seen of this (sorry, for some reason the default notification setup on GitHub for owners is only for security alerts ): but I've updated on this repo!) I assume this is still an issue? I'll investigate shortly.

@fluffynuts
Copy link
Owner

fluffynuts commented Jan 19, 2022

@ixm7 are you sure you have the correct project here? There's no Item method on IINIFile - the code above doesn't seem to be against PeanutButter's INIFile class?

However, if you were doing:

gINIFile["mySection"].Remove("myKey");

you'd be correct that the behavior was to set the key value to null (leaving the key in place, which is valid INI syntax, but, as you say, not expected)

I've just done a release to resolve this (2.0.51) - please update when it suits you (:

You can now do:

gINIFile["mySection"].Remove("myKey");
gINIFile.RemoveValue("mySection", "myKey");
giniFile.RemoveValue("mySection", "myKey", true); // will remove the section too, if it's empty (ie, last value was removed)

All of the above return true when the key was found and removed, false if the key wasn't found.

Thanks for the report.

@ixm7
Copy link
Author

ixm7 commented Jan 19, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants