notepad-plus-plus / notepad-plus-plus

Notepad++ official repository
https://notepad-plus-plus.org/
Other
22.97k stars 4.6k forks source link

Cannot clear "inherit" flag on FG/BG in styler #14197

Open pryrt opened 1 year ago

pryrt commented 1 year ago

Description of the Issue

If I have set a particular style to "inherit" (ie, right-click on both the FG and BG colors so they have the cross-hatch, and thus inherit from the DEFAULT style for the active theme), after I restart, if I change back to non-inherit and save that style, if I restart again then check, it's back to inherit.

Steps to Reproduce

  1. Fresh 8.5.7 portable
  2. restart Notepad++
  3. Style Configurator > Perl > INSTRUCTION WORD: use right-click to set fg=inherit, bg=inherit; save & close
  4. restart Notepad++
  5. Style Configurator > Perl > INSTRUCTION WORD: use right-click to set fg=not-inherit, bg=not-inherit; save & close
  6. restart Notepad++
  7. Style Configurator > Perl > INSTRUCTION WORD: it's inherit again, but it should be not-inherit.

I tried the same with Python > KEYWORDS: if I set it inherit, it properly saves. If you set them both to non-inherit, it does not.

I tried with default theme stylers.xml or the DefaultDarkTheme, with same results.

If I set FG=non-inherit and BG=inherit in step-3, and both=non-inherit in step-5, step-7 still shows FG=non-inherit, BG=inherit. If I set FG=inherit and BG=non-inherit in step-3, and both=non-inherit in step-5, step-7 still shows FG=inherit, BG=non-inherit.

Expected Behavior

Notepad++ should save the state of the "inherit" flags as being non-inherit when they had previously been saved as one-or-both-set-to-inherit and are now changed to neither-set-to-inherit

Actual Behavior

Notepad++ accepted the new neither-set-to-inherit for a single instance, but when exited and restarted, it did not save the new state, and so went back to having the "inherit" flags set on, rather than having no "inherit" flags.

Additional discussion

My guess is that it's because having no colorStyle attribute in stylers.xml/themename.xml means "non-inherit", but colorStyle="0" means inherit-FG+and+BG, colorStyle="1" means inherit-BG, and colorStyle="2" means inherit-FG ... so when you try to go from having one or more inheritedto none inherited, it doesn't properly delete that attribute when it saves the stylers.xml/themename.xml. My guess is that an easy fix would be to have colorStyle="3" be equivalent to having no colorStyle attribute and not inherit anything, so that if you use the GUI to clear the inherit on both FG and BG, it will set it to colorStyle="3". (think that might be easier than figuring out when to delete the colorStyle attribute, but I haven't looked into the codebase, so if you'd prefer to implement by deleting the attribute, that's fine.)

Debug Information

Notepad++ v8.5.7   (64-bit)
Build time : Sep  6 2023 - 23:13:49
Path : C:\usr\local\apps\npp\857\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 11 Home (64-bit)
OS Version : 22H2
OS Build : 22621.2283
Current ANSI codepage : 1252
Plugins : 
    mimeTools (2.9)
    NppConverter (4.5)
    NppExport (0.4)
pryrt commented 3 months ago

Another user has noticed this and complained about it in the Community. It's not just me seeing this bug. We need to be able to turn on and off the "inherit" flag from the GUI, and have it properly save the setting to be used the next time Notepad++ has run.

They were using 7.9.5. But I was able to confirm it again today using 8.6.8:

Notepad++ v8.6.8   (64-bit)
Build time : Jun  4 2024 - 00:30:00
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : OFF
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 22H2
OS Build : 19045.4529
Current ANSI codepage : 1252
Plugins : 
    mimeTools (3.1)
    NppConverter (4.6)
    NppExport (0.4)