From afd5e3678075864a16ead376d361ee6018221906 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 13 Apr 2018 17:22:33 +0200 Subject: [PATCH] Fixed issue #3194: Commit message control launches links on selection Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/TortoiseProc/LogDlg.cpp | 12 ++++++++++-- src/Utils/MiscUI/SciEdit.cpp | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index e261e63e7..eb7896a0e 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -13,6 +13,7 @@ Released: unreleased * Fixed issue #3184: Committing asks for user data although they are set via includeif * Fixed issue #3193: Not able to set alternative editor * Fixed issue #3195: TGitMerge tool is not saving color to correct Windows registry location + * Fixed issue #3194: Commit message control launches links on selection = Release 2.6.0 = Released: 2018-02-17 diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index bd0f6b32a..6bdf00f08 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -1885,6 +1885,11 @@ void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult) ENLINK *pEnLink = reinterpret_cast(pNMHDR); if ((pEnLink->msg == WM_LBUTTONUP) || (pEnLink->msg == WM_SETCURSOR)) { + auto pEdit = reinterpret_cast(GetDlgItem(IDC_MSGVIEW)); + CHARRANGE selRange; + pEdit->GetSel(selRange); + bool hasSelection = (selRange.cpMax != selRange.cpMin); + CString url, msg; GetDlgItemText(IDC_MSGVIEW, msg); msg.Replace(L"\r\n", L"\n"); @@ -1904,7 +1909,10 @@ void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult) if (::PathIsURL(url)) { if (pEnLink->msg == WM_LBUTTONUP) - ShellExecute(GetSafeHwnd(), L"open", url, nullptr, nullptr, SW_SHOWDEFAULT); + { + if (!hasSelection) + ShellExecute(GetSafeHwnd(), L"open", url, nullptr, nullptr, SW_SHOWDEFAULT); + } else { static RECT prevRect = { 0 }; @@ -1928,7 +1936,7 @@ void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult) } } } - else if(pEnLink->msg == WM_LBUTTONUP) + else if(pEnLink->msg == WM_LBUTTONUP && !hasSelection) { int pos = 0; if (LookLikeGitHash(url, pos)) diff --git a/src/Utils/MiscUI/SciEdit.cpp b/src/Utils/MiscUI/SciEdit.cpp index 307a1db94..6e2e2e4bd 100644 --- a/src/Utils/MiscUI/SciEdit.cpp +++ b/src/Utils/MiscUI/SciEdit.cpp @@ -822,7 +822,7 @@ BOOL CSciEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT break; } case SCN_DWELLSTART: - case SCN_HOTSPOTCLICK: + case SCN_HOTSPOTRELEASECLICK: { Sci_TextRange textrange; textrange.chrg.cpMin = static_cast(lpSCN->position); @@ -852,7 +852,7 @@ BOOL CSciEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT } if (!url.IsEmpty()) { - if (lpnmhdr->code == SCN_HOTSPOTCLICK) + if (lpnmhdr->code == SCN_HOTSPOTRELEASECLICK) ShellExecute(GetParent()->GetSafeHwnd(), L"open", url, nullptr, nullptr, SW_SHOWDEFAULT); else { -- 2.11.4.GIT