Skip to content

Commit 2456510

Browse files
committed
Fix: New files created in correct working directory (fixes #5306)
Path_NormalizeEx() now uses the canonicalized path for non-existent files, properly resolving relative paths against the original working directory instead of the module directory.
1 parent 746c477 commit 2456510

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/PathLib.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,10 @@ size_t PTHAPI Path_NormalizeEx(HPATHL hpth_in_out, const HPATHL hpth_wrkdir, boo
18741874
}
18751875
StrgDestroy(hsrch_str);
18761876
}
1877-
//else {
1878-
// //~~~Path_CanonicalizeEx(hpth_in_out, hpth_wrkdir);
1879-
//}
1877+
else {
1878+
// Use canonicalized path for non-existent files too (fixes #5306)
1879+
Path_Swap(hpth_in_out, hsrch_pth);
1880+
}
18801881
Path_Release(hsrch_pth);
18811882
}
18821883

todo/TODO.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
- Issue: [#5445](https://github.com/rizonesoft/Notepad3/issues/5445)
1010
- Code: `Notepad3.c:4788` - nested `FileSave()` returns bool, passed as FileSaveFlags
1111
- Fix: `FileSave((FileWatching.FileWatchingMode <= FWM_DONT_CARE) ? FSF_SaveAlways : FSF_None);`
12-
- [ ] **(Q2) BUG: Wrong working directory for new files** - Files created in Program Files instead of CWD
12+
- [x] **(Q2) BUG: Wrong working directory for new files** - ✅ FIXED
1313
- Issue: [#5306](https://github.com/rizonesoft/Notepad3/issues/5306)
14-
- NP3 changes CWD to exe directory during init
15-
- Fix: Resolve relative paths against original CWD before directory change
14+
- Fix: Added else block in `Path_NormalizeEx()` to use canonicalized path for non-existent files
1615
- [ ] **(Q2) BUG: Encoding detection issue** - UTF-8 files detected as DOS-852
1716
- Issue: [#5310](https://github.com/rizonesoft/Notepad3/issues/5310)
1817
- Affects German Windows 11, possibly other locales

0 commit comments

Comments
 (0)