News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Auto brackets for built in function is not working in cpp

Started by ahs_58, May 31, 2020, 07:35:13 PM

Previous topic - Next topic

ahs_58

Auto brackets after built in function in c++ was working fine when I  was using older version of codeblocks. But after installing latest version (20.03) of codeblock I need to press brackets manually.Let me clarify the matter with an example:

say I want to use sort() function for sorting a array:

In older version I just wrote sort and press ENTER key then I got like this

write sort  [Press ENTER key]  sort()

but in new version I need to press opening bracket key after writing sort
example:

write sort   [Press opening first braket key]  [Press ENTER key]   sort()


How to solve this problem? How to get old version feature that I have described above in my new codeblocks?

Thanks In Advance  :)

oBFusCATed

There is a setting for this. Are you sure it is still enabled?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ahs_58

Can you tell me exactly what that setting is?I don't know about this.

oBFusCATed

Something related to braces and completion :)
There are two settings related to this and I'm not sure which one is the one you need.
Inspect the Settings -> Editor.

p.s. I don't use this so I cannot help you more. But we have not removed it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

huycan

Let me reiterate what the OP means to say.

The problem is with the Code completion. There is an option "Add parentheses after function name auto completion" when checked, parentheses are automatically added to the function name. It worked in the past version of CB. But starting with 20.03 and all the nightly builds, it stops working.

For example, if I start typing "std:abs" ... the Code completion will give me a list of choices and after I choose (let say the first one), it will display in the editor "std::abs" (for the 20.03 ver)... but in the past, CB 17 and older... the display will be "std::abs()" ... Notice the parentheses...

Edit: This bug only happens under Windows... Linux working fine...

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

huycan

The April 20, 2019 svn11628 still working...
The Nov 18, 2020 svn11954 already broken...

In between, I don't know.. I cannot tested... because the required file "wxmsw31u_gcc_cb_wx311_2D_gcc810-mingw64.7z" is missing in download....

oBFusCATed

@killerbot: Do you know something about this? Can you re-upload the file?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Miguel Gimenez

#8
Quote from: huycan on June 10, 2020, 01:44:18 PM
The Nov 18, 2020 svn11954 already broken...

Do you mean Nov 18, 2019?

huycan

Quote from: Miguel Gimenez on June 10, 2020, 07:37:30 PM
Quote from: huycan on June 10, 2020, 01:44:18 PM
The Nov 18, 2020 svn11954 already broken...

Do you mean Nov 18, 2019?

Oops...I misread 0118... I mean the January 18, 2020.... is broken... svn11954....

huycan

Any updating on this bug.... (happens in Windows only)...

ollydbg

I debugged this issue for a while, in the latest svn code.

In the function, in my condition m_CCAutoAddParentheses is true.

void CodeCompletion::DoAutocomplete(const CCToken& token, cbEditor* ed)
{
    wxString itemText = CodeCompletionHelper::AutocompGetName(token.displayName);
    cbStyledTextCtrl* stc = ed->GetControl();
...
...
    if (token.id != -1 && m_CCAutoAddParentheses)
    {
        CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)

        TokenTree* tree = m_NativeParser.GetParser().GetTokenTree();
        const Token* tkn = tree->at(token.id);
...



I see that the token.id is always -1, this is the call stack:


#0  CodeCompletion::DoAutocomplete (this=0x5c38db8, token=..., ed=0xd09d5a8) at D:\code\cb\cb_sf_git\cccrash2019\src\plugins\codecompletion\codecompletion.cpp:1335
#1  0x694a5ac9 in cbCodeCompletionPlugin::DoAutocomplete (this=0x5c38db8, token=L"gggggccccc(): int", ed=0xd09d5a8) at D:\code\cb\cb_sf_git\cccrash2019\src\sdk\cbplugin.cpp:1028
#2  0x694bbedd in CCManager::OnEditorHook (this=0xd069478, ed=0xd09d5a8, event=...) at D:\code\cb\cb_sf_git\cccrash2019\src\sdk\ccmanager.cpp:885
#3  0x69797921 in EditorHooks::HookFunctor<CCManager>::Call (this=0xcd3ebd0, editor=0xd09d5a8, event=...) at D:\code\cb\cb_sf_git\cccrash2019\src\include\editor_hooks.h:61
#4  0x694f3b73 in EditorHooks::CallHooks (editor=0xd09d5a8, event=...) at D:\code\cb\cb_sf_git\cccrash2019\src\sdk\editor_hooks.cpp:122
...



I see that in the


void cbCodeCompletionPlugin::DoAutocomplete(const wxString& token, cbEditor* ed)
{
    DoAutocomplete(CCToken(-1, token), ed);
}


You see, the first argument of the CCToken constructor is -1, and this is actually the token.id.

I'm not sure why.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Miguel Gimenez

There is a ticket about this issue, see https://sourceforge.net/p/codeblocks/tickets/1001/

There is also a related thread discussing scope of the bug, see http://forums.next.codeblocks.org/index.php/topic,24119.0.html . Looks like it stopped working when poup code for MSW was changed just before wx3.1.2 release.

ollydbg

Quote from: Miguel Gimenez on September 11, 2020, 02:56:53 PM
There is a ticket about this issue, see https://sourceforge.net/p/codeblocks/tickets/1001/

There is also a related thread discussing scope of the bug, see http://forums.next.codeblocks.org/index.php/topic,24119.0.html . Looks like it stopped working when poup code for MSW was changed just before wx3.1.2 release.
Thanks. There are some discussion in those links.

It looks like some issue happens in the wx related code, especially the mechanism to trigger the code completion event inside C::B's SDK.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.