diff --git a/src/Dialogs.c b/src/Dialogs.c index 3a74b5685..262403eac 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -5276,7 +5276,6 @@ void SetWindowTitle(HWND hwnd, const HPATHL pthFilePath, const TITLEPROPS_T prop s_pthCachedFilePath = Path_Allocate(L""); } - if (!forceRedraw) { if (s_properties.iFormat != properties.iFormat) { forceRedraw = true; @@ -5302,20 +5301,19 @@ void SetWindowTitle(HWND hwnd, const HPATHL pthFilePath, const TITLEPROPS_T prop else if (s_properties.bReadOnly != properties.bReadOnly) { forceRedraw = true; } - else { - for (int i = 0; i < COUNTOF(s_compTitleExcerpt); ++i) { - if (s_compTitleExcerpt[i] != lpszExcerpt[i]) { - forceRedraw = true; - bExcerptChanged = true; - break; - } - } - if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath, Paths.WorkingDirectory) != 0) { - forceRedraw = true; - bFilePathChanged = true; - } + } + for (int i = 0; i < COUNTOF(s_compTitleExcerpt); ++i) { + if (s_compTitleExcerpt[i] != lpszExcerpt[i]) { + forceRedraw = true; + bExcerptChanged = true; + break; } } + // assuming path is normalized (for speed) + if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath, Paths.WorkingDirectory, false) != 0) { + forceRedraw = true; + bFilePathChanged = true; + } if (!forceRedraw) { return; diff --git a/src/Notepad3.c b/src/Notepad3.c index a2cd56a86..d75ce8951 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1632,7 +1632,7 @@ static BOOL CALLBACK _EnumWndProc2(HWND hwnd, LPARAM lParam) GetDlgItemText(hwnd, IDC_FILENAME, wchFileName, COUNTOF(wchFileName)); HPATHL hpthFileName = Path_Allocate(wchFileName); - if (Path_StrgComparePath(hpthFileName, s_pthCheckFilePath, Paths.WorkingDirectory) == 0) { + if (Path_StrgComparePath(hpthFileName, s_pthCheckFilePath, Paths.WorkingDirectory, true) == 0) { *(HWND*)lParam = hwnd; bContinue = FALSE; } @@ -3699,7 +3699,7 @@ static LRESULT _OnDropOneFile(HWND hwnd, HPATHL hFilePath, WININFO* wi) } else if (Path_IsExistingFile(hFilePath)) { //~ ignore Flags.bReuseWindow - bool const sameFile = (Path_StrgComparePath(hFilePath, Paths.CurrentFile, Paths.ModuleDirectory) == 0); + bool const sameFile = (Path_StrgComparePath(hFilePath, Paths.CurrentFile, Paths.ModuleDirectory, true) == 0); if (IsKeyDown(VK_CONTROL) || wi) { DialogNewWindow(hwnd, sameFile, hFilePath, wi); } else { @@ -11576,7 +11576,7 @@ bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags, const DocP Path_NormalizeEx(hopen_file, Paths.WorkingDirectory, true, Flags.bSearchPathIfRelative); - if (!bReloadFile && Path_StrgComparePath(hopen_file, Paths.CurrentFile, Paths.WorkingDirectory) == 0) { + if (!bReloadFile && Path_StrgComparePath(hopen_file, Paths.CurrentFile, Paths.WorkingDirectory, false) == 0) { Path_Release(hopen_file); return false; } @@ -11714,7 +11714,7 @@ bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags, const DocP } // consistent settings file handling (if loaded in editor) - Flags.bSettingsFileSoftLocked = (Path_StrgComparePath(Paths.CurrentFile, Paths.IniFile, Paths.WorkingDirectory) == 0); + Flags.bSettingsFileSoftLocked = (Path_StrgComparePath(Paths.CurrentFile, Paths.IniFile, Paths.WorkingDirectory, true) == 0); // the .LOG feature ... if (IsFileVarLogFile()) { diff --git a/src/PathLib.c b/src/PathLib.c index 06b81371a..070cca2fa 100644 --- a/src/PathLib.c +++ b/src/PathLib.c @@ -976,10 +976,18 @@ static int _StrgComparePathNormalized(const HPATHL hpth1, const HPATHL hpth2) // ---------------------------------------------------------------------------- -int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir) +int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir, const bool bNormalize) { - if (Path_IsEmpty(hpth1)) { return -1; } - if (Path_IsEmpty(hpth2)) { return +1; } + if (!bNormalize) { + return _StrgComparePathNormalized(hpth1, hpth2); + } + + if (Path_IsEmpty(hpth1)) { + return -1; + } + if (Path_IsEmpty(hpth2)) { + return +1; + } HPATHL hpth1_tmp = Path_Copy(hpth1); HPATHL hpth2_tmp = Path_Copy(hpth2); diff --git a/src/PathLib.h b/src/PathLib.h index d187379fe..ead66721a 100644 --- a/src/PathLib.h +++ b/src/PathLib.h @@ -99,7 +99,7 @@ bool PTHAPI Path_IsRoot(const HPATHL hpth); bool PTHAPI Path_IsValidUNC(const HPATHL hpth); bool PTHAPI Path_IsExistingDirectory(const HPATHL hpth); -int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir); +int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir, const bool bNormalize); bool PTHAPI Path_RemoveFileSpec(HPATHL hpth_in_out); bool PTHAPI Path_RenameExtension(HPATHL hpth, LPCWSTR ext); void PTHAPI Path_ExpandEnvStrings(HPATHL hpth_in_out); diff --git a/src/Styles.c b/src/Styles.c index ac18c4d62..354293bbc 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -927,7 +927,7 @@ static void _ReadFromIniCache() { bool Style_ImportFromFile(const HPATHL hpath) { bool const bHaveFileResource = Path_IsNotEmpty(hpath); - bool const bIsStdIniFile = bHaveFileResource ? (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory) == 0) : false; + bool const bIsStdIniFile = bHaveFileResource ? (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory, true) == 0) : false; bool result = bIsStdIniFile ? OpenSettingsFile(__func__) : (bHaveFileResource ? LoadIniFileCache(hpath) : true); if (result) { @@ -1155,7 +1155,7 @@ bool Style_ExportToFile(const HPATHL hpath, bool bForceAll) return false; } - bool const bIsStdIniFile = (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory) == 0); + bool const bIsStdIniFile = (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory, true) == 0); // special handling of standard .ini-file bool ok = false;