Skip to content

fix: Select File/Folder starts in the real path's folder instead of the caption - #3806

Merged
sdottaka merged 1 commit into
WinMerge:masterfrom
pcbeingused33:fix/select-file-real-path
Dec 3, 2026
Merged

sdottaka merged 1 commit into
WinMerge:masterfrom
pcbeingused33:fix/select-file-real-path

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3791 and #3795, same root cause in another entry of the path bar's context menu: "Select File/Folder..." now opens the dialog in the folder of the real path, not in a folder derived from the displayed text.

  • Custom caption (e.g. WinMergeU.exe /dl "Left" /dr "Right" C:\work\a.txt C:\work\b.txt, as VCS tools do): the initial folder was computed from Left, so the dialog did not start next to the compared file. It now starts in C:\work.
  • Long path in a narrow pane: the window text is the output of PathCompactPath (C:\...\proj\a.txt), so the initial folder was C:\...\proj, which does not exist. It now uses the full path.

Cause: CFilepathEdit::OnContextMenuSelected (ID_EDITOR_SELECT_FILE) called GetWindowText() and passed that text to paths::GetParentPath. The window text is the caption or the compacted display text set by RefreshDisplayText, while the real path is kept in m_sFilepath (already used by Copy Full Path / Copy Filename since #3791/#3795, and by Edit Path).

Fix: when m_sFilepath is set, the initial folder is paths::GetParentPath(m_sFilepath); otherwise the previous window-text logic (including stripping the leading * modified mark) is kept unchanged.

Test: the control is MFC (Windows-only) with no unit-test harness, so the initial-folder logic was checked in a standalone C++ program using paths::GetParentPath copied from the source. Before the change 4 of 6 cases fail (custom caption, caption with the modified mark, compacted path, folder caption); after it all 6 pass, including a plain uncaptioned path and a control without a real path (fallback unchanged).

Disclosure: this change was prepared with the assistance of an AI coding agent (Claude) and has not been compiled or exercised in the GUI on Windows.

…he caption

The path bar's "Select File/Folder..." took the initial folder from the
window text, which can be a custom caption (/dl, /dr, ...) or a path
compacted by PathCompactPath. Use m_sFilepath when it is set, as Copy Full
Path and Copy Filename already do (WinMerge#3791, WinMerge#3795).
@sdottaka
sdottaka merged commit fd50d4e into WinMerge:master Dec 3, 2026
3 checks passed
@sdottaka

sdottaka commented Dec 3, 2026

Copy link
Copy Markdown
Member

Thank you!

@sdottaka sdottaka added this to the v2.16.61 milestone Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants