summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-07-29 13:37:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-07-29 13:37:35 +0300
commitc5dee6c89f778c4fc2598cfce5e361985a13abb8 (patch)
tree2dec2746ea6be88c3511513e018060cc1a34923f /plugins/TabSRMM
parent4347e469ab0a18edbc5b7bea431829fe16883054 (diff)
fixes #3128 (tabSRMM: автодополнение ника (Tab) добавляет пробел, если включены настройки про добавление к нику двоеточия/запятой, и не добавляет, если они отключены)
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 6387d37a2c..a7b9823c25 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -1870,16 +1870,12 @@ bool CMsgDialog::TabAutoComplete()
return false;
bool isTopic = false, isRoom = false;
- wchar_t *pszName = nullptr;
wchar_t *pszText = (wchar_t *)mir_calloc((iLen + 10) * sizeof(wchar_t));
gt.flags = GT_DEFAULT;
gt.cb = (iLen + 9) * sizeof(wchar_t);
m_message.SendMsg(EM_GETTEXTEX, (WPARAM)& gt, (LPARAM)pszText);
- if (start > 1 && pszText[start - 1] == ' ' && pszText[start - 2] == ':')
- start -= 2;
-
if (m_wszSearchResult != nullptr) {
int cbResult = (int)mir_wstrlen(m_wszSearchResult);
if (start >= cbResult && !wcsnicmp(m_wszSearchResult, pszText + start - cbResult, cbResult)) {
@@ -1904,11 +1900,14 @@ LBL_SkipEnd:
if (topicStart > 5 && wcsstr(&pszText[topicStart - 6], L"/topic") == &pszText[topicStart - 6])
isTopic = true;
}
+
if (m_wszSearchQuery == nullptr) {
m_wszSearchQuery = mir_wstrndup(pszText + start, end - start);
m_wszSearchResult = mir_wstrdup(m_wszSearchQuery);
m_pLastSession = nullptr;
}
+
+ const wchar_t *pszName = nullptr;
if (isTopic)
pszName = m_si->ptszTopic;
else if (isRoom) {
@@ -1921,18 +1920,25 @@ LBL_SkipEnd:
replaceStrW(m_wszSearchResult, nullptr);
if (pszName != nullptr) {
- m_wszSearchResult = mir_wstrdup(pszName);
if (end != start) {
- ptrW szReplace;
- if (!isRoom && !isTopic && g_Settings.bAddColonToAutoComplete && start == 0) {
- szReplace = (wchar_t *)mir_alloc((mir_wstrlen(pszName) + 4) * sizeof(wchar_t));
- mir_wstrcpy(szReplace, pszName);
- mir_wstrcat(szReplace, g_Settings.bUseCommaAsColon ? L", " : L": ");
- pszName = szReplace;
+ CMStringW szReplace;
+ if (!isRoom && !isTopic && start == 0) {
+ szReplace = pszName;
+ if (g_Settings.bUseCommaAsColon)
+ szReplace.AppendChar(',');
+ else if (g_Settings.bAddColonToAutoComplete)
+ szReplace.AppendChar(':');
+ szReplace.AppendChar(' ');
+ m_wszSearchResult = szReplace.Detach();
+ pszName = m_wszSearchResult;
}
+ else m_wszSearchResult = mir_wstrdup(pszName);
+
m_message.SendMsg(EM_SETSEL, start, end);
m_message.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)pszName);
}
+ else m_wszSearchResult = mir_wstrdup(pszName);
+
return true;
}