Patch 1279
https://sourceforge.net/p/codeblocks/tickets/1279This is a request for comments.
ccmanager ignores completion requests when its length is the same as the previously mispelled request.
Example:
Create a virgin wx project. type "OnC", in the last method (OnAbout).
Completion will suggest OnClose. Hit escape.
Backup and change C to Q for OnQuit. No suggestions occur.
All three letter requests will be ignored until a 4th letter is typed.
This patch adds an additional test of the pattern text to determine if the last request is actually different from the current.
It works for both plugins codecompletion and clangd_client.
Index: src/include/ccmanager.h
===================================================================
--- src/include/ccmanager.h (revision 12842)
+++ src/include/ccmanager.h (working copy)
@@ -223,6 +223,7 @@
int caretStart;
int tokenStart;
int editorZoom;
+ wxString trigger;
};
LastACLaunchState m_LastACLaunchState;
Index: src/sdk/ccmanager.cpp
===================================================================
--- src/sdk/ccmanager.cpp (revision 12842)
+++ src/sdk/ccmanager.cpp (working copy)
@@ -516,14 +516,19 @@
cbStyledTextCtrl* stc = ed->GetControl();
int tknEnd = stc->GetCurrentPos();
+ int tknStart = stc->WordStartPosition(tknEnd, true);
+ wxString trigger = stc->GetTextRange(tknStart, tknEnd);
if (tknEnd == m_LastACLaunchState.caretStart && stc->GetZoom() == m_LastACLaunchState.editorZoom && !m_AutocompTokens.empty())
{
DoBufferedCC(stc);
- return;
+ // If the completion trigger is the same as last, the old cached completions have already been shown
+ // else they've just been cached, but not yet shown.
+ if (m_LastACLaunchState.trigger.Length() and (m_LastACLaunchState.trigger == trigger)) //(ph 2022/06/28)
+ return;
}
+ // Record the new completion trigger
+ m_LastACLaunchState.trigger = stc->GetTextRange(tknStart,tknEnd); //(ph 2022/06/28)
- int tknStart = stc->WordStartPosition(tknEnd, true);
-
m_AutocompTokens = ccPlugin->GetAutocompList(event.GetInt() == FROM_TIMER, ed, tknStart, tknEnd);
if (m_AutocompTokens.empty())
return;