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

lua preferences: do not add enum default value as additional item #11175

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

ChristianBirzer
Copy link
Contributor

While trying to add a lua script preference setting of type "enum" (combobox) I noticed that the default value is set as an additional selection value.
According to the preferenceExamples.lua script, the values should include the default value:

dt.preferences.register("preferenceExamples",        -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
                        "preferenceExamplesEnum",  -- name
                        "enum",                       -- type
                        "Example Enum",              -- label
                        "Example Enum Tooltip",      -- tooltip
                        "Enum 1",                     -- default
                        "Enum 1", "Enum 2")           -- values

("Enum 1" is in the values and additionally as default value).
Doing so, the default value will be in the preferences drop down selection twice.

As it seems that no script (except the examples) from the distro currently uses the enum, I guess it's ok to change the behavior so that the default value is stored but not added to the list for the combobox.

The alternative is to omit the default value in the values enumeration. But than it will be impossible to have a "ordered" list where the default is not the first item.

As I do not have an overview of the entire impact of this small change, please check twice before merging. Thank you!

@TurboGit TurboGit requested a review from wpferguson February 19, 2022 11:22
@TurboGit TurboGit added this to the 4.0 milestone Feb 19, 2022
@TurboGit TurboGit added bugfix pull request fixing a bug lua labels Feb 19, 2022
@wpferguson
Copy link
Member

@TurboGit I'll check it out. It may take a little while as I'm pretty busy right now. Maybe a week or so...

@wpferguson
Copy link
Member

Tested and it looks good to me. Thanks @ChristianBirzer

Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good then, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix pull request fixing a bug lua
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants