Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

question on how to trigger evt(cbEVT_COMPLETE_CODE)

(1/5) > >>


--- Code: ---            // auto suggest list can be triggered either:
            // 1, some number of chars are entered
            // 2, an interested char belong to alChars is entered
            int autolaunchCt = Manager::Get()->GetConfigManager(wxT("ccmanager"))->ReadInt(wxT("/auto_launch_count"), 3);
            if (   (pos - wordStartPos >= autolaunchCt && !stc->AutoCompActive())
                || pos - wordStartPos == autolaunchCt + 4 )
                CodeBlocksEvent evt(cbEVT_COMPLETE_CODE);
            else if (alChars->second.find(ch) != alChars->second.end())
                m_AutoLaunchTimer.Start(10, wxTIMER_ONE_SHOT);
                m_AutocompPosition = pos;

--- End code ---

This is some code snippet in the ccmanager.cpp, you see there is a condition

--- Code: ---pos - wordStartPos == autolaunchCt + 4
--- End code ---

I think this condition should be removed, this cause extra refresh of the suggestion list

For example, when I hit a dot, I get some suggestion list like "Method1", then I continue to type the "M", "e", "t"... When I hit "d", the whole code suggestion list will get refreshed. (In my case, autolaunchCt is 2), I think it just waste a lot of time, right?

I don't understand what is your problem. Can you try to describe it?

My original reason was that a CC plugin might return a massive amount of results, especially if CC is initiated with no (or only one letter) context.  This allows the CC plugin to return only the most likely results, then later expand to all matching results once the context is more exact.

When using this with clang, I cache the symbol dump for the refine step (or if a user requests CC again in the same spot).  Although, I do not know what the current state of that is; I have not followed its development.

I don't understand. What is supposed to happen?
Should the auto completion auto reload when the user types 4 character or the completion word becomes 4 characters long?
I see the former behaviour. It looks rather strange.

Why don't we update the list on every keystroke? Why don't we update the list on every backspace or delete character.
You can try sublime text 3 for a good implementation of this.


--- Quote from: oBFusCATed on August 17, 2017, 09:05:18 pm ---I don't understand what is your problem. Can you try to describe it?

--- End quote ---
OK, let me explain it in more details.
Suppose you have a class:

--- Code: ---class AAA
void Method1();
void Method2();
void Method3();
void Method4();
void Method5();
void Method6();
int aaa;
int bbb;
int ccc;

AAA obj;

--- End code ---

Now, when you hit the ".", the suggestion list will show all the member functions and member variables. This is because "." is an interesting character. This is how the "else if" clause in my first post describes.  "else if (alChars->second.find(ch) != alChars->second.end())", this trigger a timer, and further trigger a evt(cbEVT_COMPLETE_CODE).

Now, you continue typing type "M", "e", .... The suggestion list get reduced, such as the member variables are removed from the suggestion list.
But when you get a condition that "pos - wordStartPos == autolaunchCt + 4", you trigger a evt(cbEVT_COMPLETE_CODE) again. I think the second evt(cbEVT_COMPLETE_CODE) is not necessary, because all the suggestion list is already generated, when you enter more characters, you are just reduce the suggestion list my prefix match. I think all the suggestion list items are already cached in the suggestion list.

Note: a evt(cbEVT_COMPLETE_CODE) normally ask the plugin to do a expression solving of the current statement, which is not a simple task, at least in our buildin CC plugin.


[0] Message Index

[#] Next page

Go to full version