Smart brackets / parentheses deletes parenthesis

General questions regarding the usage of CodeLite
guyr
CodeLite Enthusiast
Posts: 11
Joined: Wed Feb 01, 2017 11:16 am
Genuine User: Yes
IDE Question: C++
Contact:

Smart brackets / parentheses deletes parenthesis

Post by guyr »

I'm fixing up somebody else's old code. I encountered an odd scenario which I was able to narrow down using this example:

printf("Maximum of 0 and 6: %d\n", std::max(0, 6); // required closing parenthesis is missing

In Settings - Preferences - Edit, if the value "Smart brackets / parentheses" is checked, then if the cursor is between the '6' and ')' inside std::max(), and I type a right parenthesis, the editor will ignore that keystroke and simply move the cursor to the right. If instead the cursor is between the ')' and ';' , the editor will insert that character. Took me awhile to isolate why this was happening.

On the Preferences page, for the "Smart brackets / parentheses" option, the help text says: "When typing ']' or ')' next to a ']' or ')' Move the caret one position to the right". So perhaps this is the desired behavior, but for me at least this behavior was unexpected. Could the editor insert the character, AND move the caret one position to the right? Replacing a purposely typed character with caret movement doesn't seem like the right thing to do. I've unchecked this option, and now the editor is more predictable.

Thanks.

User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Smart brackets / parentheses deletes parenthesis

Post by Jarod42 »

I would say it is the expected behavior.

Opening (,[,{ would add the closing part (at least in some context).
To avoid the double closing, there is this "smart" option.

(I disable it too BTW).

Post Reply