Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: ahs_58 on May 31, 2020, 07:35:13 pm

Title: Auto brackets for built in function is not working in cpp
Post by: ahs_58 on May 31, 2020, 07:35:13 pm
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  :)
Title: Re: Auto brackets for built in function is not working in cpp
Post by: oBFusCATed on May 31, 2020, 07:42:08 pm
There is a setting for this. Are you sure it is still enabled?
Title: Re: Auto brackets for built in function is not working in cpp
Post by: ahs_58 on May 31, 2020, 07:45:44 pm
Can you tell me exactly what that setting is?I don't know about this.
Title: Re: Auto brackets for built in function is not working in cpp
Post by: oBFusCATed on May 31, 2020, 08:21:11 pm
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.
Title: Re: Auto brackets for built in function is not working in cpp
Post by: huycan on June 10, 2020, 12:51:18 am
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...
Title: Re: Auto brackets for built in function is not working in cpp
Post by: oBFusCATed on June 10, 2020, 10:51:20 am
Can you find the night build which broke this?
Title: Re: Auto brackets for built in function is not working in cpp
Post by: huycan on June 10, 2020, 01:44:18 pm
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....
Title: Re: Auto brackets for built in function is not working in cpp
Post by: oBFusCATed on June 10, 2020, 06:43:13 pm
@killerbot: Do you know something about this? Can you re-upload the file?
Title: Re: Auto brackets for built in function is not working in cpp
Post by: Miguel Gimenez on June 10, 2020, 07:37:30 pm
The Nov 18, 2020 svn11954 already broken...

Do you mean Nov 18, 2019?
Title: Re: Auto brackets for built in function is not working in cpp
Post by: huycan on June 10, 2020, 08:49:35 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....
Title: Re: Auto brackets for built in function is not working in cpp
Post by: huycan on July 14, 2020, 10:56:47 pm
Any updating on this bug.... (happens in Windows only)...
Title: Re: Auto brackets for built in function is not working in cpp
Post by: ollydbg on September 11, 2020, 02:04:00 pm
I debugged this issue for a while, in the latest svn code.

In the function, in my condition m_CCAutoAddParentheses is true.

Code
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:

Code
#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

Code
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.
Title: Re: Auto brackets for built in function is not working in cpp
Post by: 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/ (https://sourceforge.net/p/codeblocks/tickets/1001/)

There is also a related thread discussing scope of the bug, see http://forums.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.
Title: Re: Auto brackets for built in function is not working in cpp
Post by: ollydbg on September 12, 2020, 04:31:40 pm
There is a ticket about this issue, see https://sourceforge.net/p/codeblocks/tickets/1001/ (https://sourceforge.net/p/codeblocks/tickets/1001/)

There is also a related thread discussing scope of the bug, see http://forums.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.