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

"PartialSp" is visible in pinyin options despite of it has been set to hidden #1137

Open
rocka opened this issue Sep 24, 2024 · 2 comments
Open

Comments

@rocka
Copy link
Member

rocka commented Sep 24, 2024

The option partialSp is declared as OptionWithAnnotation<bool, OptionalHideInDescription>

https://github.com/fcitx/fcitx5-chinese-addons/blob/64e2a072e92ca06b08b9fd82d7549f86cc0699a9/im/pinyin/pinyin.h#L117-L119

and set to hidden in pyConfig_

https://github.com/fcitx/fcitx5-chinese-addons/blob/64e2a072e92ca06b08b9fd82d7549f86cc0699a9/im/pinyin/pinyin.cpp#L785

but it's still vislble in pinyin options:

image


  • fcitx5 5.1.10
  • fcitx5-chinese-addons 5.1.6
  • fcitx5-configtool 5.1.6
@rocka
Copy link
Member Author

rocka commented Sep 24, 2024

After some debugging (on Android), I found that option->skipDescription() always returns false when dumping description of pyConfig_.fuzzyConfig

if (option->skipDescription()) {
continue;
}

@wengxt
Copy link
Member

wengxt commented Sep 25, 2024

Did some more investigation, looks like a design flaw in fcitx::Configuration.

Option that wraps a config relies on the subConfigSkeleton() to generate description.

However subConfigSkeleton will always return a copied fcitx::Configuration from "defaultValue_".

The reason for this design is that, subConfigSkeleton not only returns the directly wrapped Configuration subclass, but also strip vector from vector. In the vector case, there is no Configuration object, so it has to be a new instance.

Copy constructor defined with FCITX_CONFIGURATION, will only copy the option value and leave all the annotation untouched.

So in short, two issues:

  1. subConfigSkeleton always return a new instance. The function signature is std::unique_ptr, so unfortunately, it has to be a new instance for now. One possible way is solve this is to create a new Configuration and do a forwarding from existing object, instead of return a real new instance.
  2. the value returned by subConfigSkeleton only copies values. In the past, we are having a similar issue for defaultValue. At that time, syncDefaultValueToCurrent is introduced. Maybe, we can introduce a new method to copy annotation value too.

@wengxt wengxt transferred this issue from fcitx/fcitx5-chinese-addons Sep 25, 2024
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