Use %LOCALAPPDATA% to store ini file for WinGet installation
With this change, notepad4 will use %LOCALAPPDATA%\notepad4 folder to store ini file if it is running from WinGet installation and keep the ini file in the exe folder unchanged. This will fix the WinGet upgrade issue.
Also I remove %USERPROFILE% and %APPDATA% support. %USERPROFILE% is not supposed to used for storing app configurations. It is meant for user files. %APPDATA% will roaming across machine, but notepad4.ini contains machine specific data (e.g. window location) so we should not store it there.
Update: restored USERPROFILE and APPDATA support since people may already depend on that.
Instead of checking _Microsoft.Winget.Source_, how about just check whether Notepad4.ini from Notepad4.exe folder is writeable?
Instead of checking
_Microsoft.Winget.Source_, how about just check whether Notepad4.ini from Notepad4.exe folder is writeable?
Unfortunately Notepad4.ini is writable in WinGet installation folder, so we can't rely on that to check.
@zufuliu any other comments?
Also I remove %USERPROFILE% and %APPDATA% support.我也删除了%USERPROFILE%和%APPDATA%支持。 %USERPROFILE% is not supposed to used for storing app configurations. It is meant for user files. %USERPROFILE%不应用于存储应用程序配置。它是用于用户文件的。 %APPDATA% will roaming across machine, but notepad4.ini contains machine specific data (e.g. window location) so we should not store it there. %APPDATA%将在机器上漫游,但 notepad4.ini 包含机器特定的数据(例如窗口位置),因此我们不应该将其存储在那里。
There are a lot of settings that I wish to roam, such as my configurations for some custom syntax highlighting.
Can we refer to the approach of Total Commander in this regard, using redirection to split the ini?
For example, the following excerpt
[Layout]
BreadCrumbBar=1
CmdLine=1
CurDir=1
DirectoryTabs=1
DriveBar1=1
DriveBar2=1
DriveBarFlat=1
DriveCombo=0
HistoryHotlistButtons=1
InterfaceFlat=1
KeyButtons=1
StatusBar=1
TabHeader=1
XPthemeBg=1
[Associations]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[Command line history]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SplitPerFile]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SyncOptions]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[USER]
RedirectSection=%COMMANDER_PATH%\User\User.ini
If there is a RedirectSection value encountered during the section, redirect to another ini file.
This method can also be used to set different configurations for different users on the same computer.
Also I remove %USERPROFILE% and %APPDATA% support.我也删除了%USERPROFILE%和%APPDATA%支持。 %USERPROFILE% is not supposed to used for storing app configurations. It is meant for user files. %USERPROFILE%不应用于存储应用程序配置。它是用于用户文件的。 %APPDATA% will roaming across machine, but notepad4.ini contains machine specific data (e.g. window location) so we should not store it there. %APPDATA%将在机器上漫游,但 notepad4.ini 包含机器特定的数据(例如窗口位置),因此我们不应该将其存储在那里。
There are a lot of settings that I wish to roam, such as my configurations for some custom syntax highlighting.
Can we refer to the approach of Total Commander in this regard, using redirection to split the ini?
For example, the following excerpt
[Layout] BreadCrumbBar=1 CmdLine=1 CurDir=1 DirectoryTabs=1 DriveBar1=1 DriveBar2=1 DriveBarFlat=1 DriveCombo=0 HistoryHotlistButtons=1 InterfaceFlat=1 KeyButtons=1 StatusBar=1 TabHeader=1 XPthemeBg=1 [Associations] RedirectSection=%COMMANDER_PATH%\User\User.ini [Command line history] RedirectSection=%COMMANDER_PATH%\User\History.ini [SplitPerFile] RedirectSection=%COMMANDER_PATH%\User\History.ini [SyncOptions] RedirectSection=%COMMANDER_PATH%\User\User.ini [USER] RedirectSection=%COMMANDER_PATH%\User\User.iniIf there is a RedirectSection value encountered during the section, redirect to another ini file.
This method can also be used to set different configurations for different users on the same computer.
This goes beyond the scope of this change. You should open a different issue to track it.
@zufuliu I updated the PR to restore support for PROFILE and APPDATA, please take another look.
Before applying the change, I'm going to rewrite FindIniFile(), current code is bit complicate (e.g. CheckIniFile() been called 5 times, so likely the rfidList loop and your winget check code), also TestIniFile() and CreateIniFile() seems can be eliminated.
https://github.com/zufuliu/notepad4/blob/fd2208379ec4b00c0ee4fe85c00d39055cb8c698/src/Notepad4.cpp#L546-L548