diff options
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 8fa4a7864d..350f40ef20 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -205,21 +205,19 @@ LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) wchar_t *pszWord = (wchar_t*)_alloca(8192); pszWord[0] = '\0'; - int iCharIndex = m_log.SendMsg(EM_CHARFROMPOS, 0, (LPARAM)&ptl); - if (iCharIndex < 0) - break; - - int start = m_log.SendMsg(EM_FINDWORDBREAK, WB_LEFT, iCharIndex); - int end = m_log.SendMsg(EM_FINDWORDBREAK, WB_RIGHT, iCharIndex); + if (sel.cpMin == sel.cpMax) { // get a word under cursor + int iCharIndex = m_log.SendMsg(EM_CHARFROMPOS, 0, (LPARAM)& ptl); + if (iCharIndex < 0) + break; - if (end - start > 0) { - CHARRANGE cr; - cr.cpMin = start; - cr.cpMax = end; + sel.cpMin = m_log.SendMsg(EM_FINDWORDBREAK, WB_LEFT, iCharIndex); + sel.cpMax = m_log.SendMsg(EM_FINDWORDBREAK, WB_RIGHT, iCharIndex); + } + if (sel.cpMax > sel.cpMin) { TEXTRANGE tr = { 0 }; - tr.chrg = cr; - tr.lpstrText = (wchar_t*)pszWord; + tr.chrg = sel; + tr.lpstrText = pszWord; int iRes = m_log.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr); if (iRes > 0) { wchar_t *p = wcschr(pszWord, '\r'); |