User forums > Using Code::Blocks
Can code completion be made contextual?
carra:
Code completion in C::B is really useful, but it seems to behave worse when there are big lists of candidates. This happens whenever you include big headers (such as <windows.h>), because the only critera for suggesting candidates seems to alphabetic sorting. Think, for instance, a Windows program where I have the following:
--- Code: --- UniString U( const string& Text )
{
UniString Result = U( Text.c_str() );
Result += '\0';
return Re <-- HERE
}
--- End code ---
For anyone seeing this code, it would be very obvious that I want to write "Result", however due to windows definitions Code Completion suggests the following:
--- Code: ---ReadClassStg
ReadClassStm
ReadConsole
ReadConsoleA
... (VERY long list)
--- End code ---
All these Windows definitions have nothing to do with what I am writing. But the problem is that, being THAT many, in many simple cases you end up having to write almost the whole word yourself to get the right suggestion. This is a clear indication that, when including big headers, a simple alphabetic sort is not the most useful criteria.
So my question here is if it would be feasible to change priorities in the suggestion list, so that local definitions are suggested first. In my experience I have found this would get the first suggestion right in a high percentage of cases, and would therefore save lots of times when programming.
What do you think about this?
ollydbg:
I just review the code, and see that:
--- Code: ---int CodeCompletion::CodeComplete()
--- End code ---
adding all the tokens to show, and sort the show items.
If a Token is a local variable(automatic variable), it will have Token->m_IsTemp==true.
So, maybe, we can firstly scan those tokens, and put them in the beginning of the codecompletion list.
I'm currently working on other part of CC, so it is great if you can help us. :)
Add to:
005252
oBFusCATed:
--- Code: ---if (result.size() <= m_CCMaxMatches)
--- End code ---
Is this line correct?
I think this is a massive bug, because if there are more matches than the limit the list with matches won't be shown at all.
Am I correct?
MortenMacFly:
--- Quote from: oBFusCATed on July 07, 2012, 02:11:33 pm ---
--- Code: ---if (result.size() <= m_CCMaxMatches)
--- End code ---
Is this line correct?
--- End quote ---
Yes - look below, the else tree will show a warning asking the user to increase the number of results. So not "nothing" is shown, but a warning.
Besides: The default number of results is really big - if this number is exceeded, it is more likely that something is seriously screwed.
oBFusCATed:
I've set it to 200 in the UI, but this value is ignored, as "/max/matches" is only read, never set.
The config value set in the UI is "/max_matches" as far as I can see.
But again in my opinion this is broken, because the max_matches config variable should limit only the results shown in the listctrl, not the searching phaze.
Navigation
[0] Message Index
[#] Next page
Go to full version