From 8c5433c0465464d9f45237fdc2e0d43a453d271b Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Wed, 4 Jan 2023 12:58:45 +0100 Subject: [PATCH] +fix: handling of editing own settings (in this case: disable file watching) --- Build/Notepad3.ini | 8 ++++---- src/Dialogs.c | 1 + src/Notepad3.c | 18 ++++++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index cb57f1095..0760d0bb0 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -11,7 +11,6 @@ SettingsVersion=5 ;TimeStampFormat= (-> $Date: %s $) {Print format should fit to TimeStampRegEx} ;DefaultDirectory= ;DefaultExtension=txt -;DefaultWindowPosition= ;DenyVirtualSpaceAccess=0 ;filebrowser.exe=minipath.exe ;grepWin.exe=grepWinNP3.exe @@ -111,8 +110,11 @@ SettingsVersion=5 ;28=History ;29=Always On Top ;30=Search in Files -[Custom Colors] [Styles] +[Window] +;x DefaultWindowPosition= +[Suppressed Messages] +[Custom Colors] [Common Base] [2nd Common Base] [Text Files] @@ -169,8 +171,6 @@ SettingsVersion=5 [Web Source Code] [XML Document] [YAML] -[Window] -[Suppressed Messages] [Recent Files] [Recent Find] [Recent Replace] diff --git a/src/Dialogs.c b/src/Dialogs.c index 21d1ff68a..b88340e4f 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -4760,6 +4760,7 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, const HPATHL hFilePath, WI if (Path_IsNotEmpty(hFilePath)) { HPATHL hfile_pth = Path_Copy(hFilePath); Path_QuoteSpaces(hfile_pth, true); + StrgCat(hparam_str, L" "); StrgCat(hparam_str, Path_Get(hfile_pth)); Path_Release(hfile_pth); } diff --git a/src/Notepad3.c b/src/Notepad3.c index 5c1ed3fcd..534a292e5 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -11083,7 +11083,6 @@ bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags) if (SciCall_GetZoom() != 100) { ShowZoomCallTip(); } - ResetFileObservationData(true); UndoRedoReset(); @@ -11238,6 +11237,10 @@ bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags) _ResetFileWatchingMode(); } } + + // consistent settings file handling (if loaded in editor) + Flags.bSettingsFileSoftLocked = (Path_StrgComparePathNormalized(Paths.CurrentFile, Paths.IniFile) == 0); + InstallFileWatching(true); // the .LOG feature ... @@ -11261,8 +11264,6 @@ bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags) EditSetSelectionEx(iAnchorPos, iCaretPos, -1, -1); } - // consistent settings file handling (if loaded in editor) - Flags.bSettingsFileSoftLocked = (StringCchCompareXIW(Path_Get(Paths.CurrentFile), Path_Get(Paths.IniFile)) == 0); UpdateSaveSettingsCmds(); if (SciCall_GetZoom() != 100) { ShowZoomCallTip(); @@ -11696,9 +11697,7 @@ bool FileSave(FileSaveFlags fSaveFlags) LONG const answer = InfoBoxLng(typ, L"ReloadExSavedCfg", IDS_MUI_RELOADSETTINGS, tch); if (IsYesOkay(answer)) { ///~SaveAllSettings(true); ~ already saved (CurrentFile) - HPATHL hempty_pth = Path_Allocate(NULL); - DialogNewWindow(Globals.hwndMain, false, hempty_pth, NULL); - Path_Release(hempty_pth); + DialogNewWindow(Globals.hwndMain, false, Paths.CurrentFile, NULL); CloseApplication(); } } @@ -12407,6 +12406,11 @@ void InstallFileWatching(const bool bInstall) { static HANDLE _hObserverThread = INVALID_HANDLE_VALUE; static HANDLE _hCurrFileHandle = INVALID_HANDLE_VALUE; // exclusive lock + // don't install FileWathing on own Settings IniFile + if (bInstall && Flags.bSettingsFileSoftLocked) { + return; + } + HPATHL hdir_pth = Path_Copy(Paths.CurrentFile); Path_RemoveFileSpec(hdir_pth); @@ -12428,6 +12432,8 @@ void InstallFileWatching(const bool bInstall) { // Terminate previous watching if (bTerminate) { + ResetFileObservationData(true); + KillTimer(Globals.hwndMain, ID_WATCHTIMER); if (IS_VALID_HANDLE(_hObserverThread)) {