News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Code completion occurring inside comments

Started by zabzonk, February 20, 2013, 12:18:11 PM

Previous topic - Next topic

zabzonk

Using C::B 12.11, I am getting code completion popping up inside C++ comments. Am I alone in this (I did search before posting), and is there an easy way of stopping it? Screenshot here http://imgur.com/bL9VtGb .



oBFusCATed

I'd rather say this is a feature (at least for me) :)
(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!]

zabzonk

Well, it's not for me! I find it intensely irritating having CC pop up when I'm writing non-program text. At the very least, it should be optional.

ollydbg

I think it is a cc bug, I can't reproduce this issue.
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.

Alpha

The guard:
codecompletion.cpp: 2874

    if (   control->IsString(style)
        || control->IsComment(style)
        || control->IsCharacter(style)
        || control->IsPreprocessor(style) )
    {
        return;
    }

should already prevent this.  Can you post a test case this behavior is occurring on?

zabzonk

#5
Further investigation indicates that the behaviour is actually quite bizarre. If I create a new header file in a console project and start adding C++-style comments (but nothing else - no actual code), then the first word that can cause CC to fire will do so. So, if I enter;

// this

then the code completion list pops up for "this", and for any other completable words as type them. If I enter a newline, then it seems the behaviour goes back to normal, and no CC takes place in the comment.  So it looks like the code for IsComment() may be a bit buggy.

ollydbg

Quote from: Neil Butterworth on February 20, 2013, 03:50:02 PM
...So it looks like the code for IsComment() may be a bit buggy.
I agree with you, you can report to scintilla :).
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.

danselmi

IsComment(style) is part of cbStyledTextCtrl not scintilla!
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

Jenna

Quote from: danselmi on February 20, 2013, 04:12:13 PM
IsComment(style) is part of cbStyledTextCtrl not scintilla!
The problem is the control->GetStyleAt() function, that always returns 0 as style for the last position of a document.
And that's a Scintilla issue.

zabzonk

#9
Is this a new Scintilla issue? Because I'm pretty positive it didn't happen prior to C::B 12.11.

Edit: Oh, yes it does (just tested it) - I wonder why I've never noticed it before?

Jenna

Quote from: jens on February 20, 2013, 06:19:39 PM
Quote from: danselmi on February 20, 2013, 04:12:13 PM
IsComment(style) is part of cbStyledTextCtrl not scintilla!
The problem is the control->GetStyleAt() function, that always returns 0 as style for the last position of a document.
And that's a Scintilla issue.

Maybe not an issue, because the last postion is not styled at all, so retuzrning a zero.style might be considered the correct way to handle it.

I attach a patch with a quick (and more or less ugly) fix for this.
If the caret is on last position of a document (with length > 0) we use the style for the last character.


Jenna

Quote from: jens on February 26, 2013, 10:51:50 AM
Quote from: jens on February 20, 2013, 06:19:39 PM
Quote from: danselmi on February 20, 2013, 04:12:13 PM
IsComment(style) is part of cbStyledTextCtrl not scintilla!
The problem is the control->GetStyleAt() function, that always returns 0 as style for the last position of a document.
And that's a Scintilla issue.

Maybe not an issue, because the last postion is not styled at all, so retuzrning a zero.style might be considered the correct way to handle it.

I attach a patch with a quick (and more or less ugly) fix for this.
If the caret is on last position of a document (with length > 0) we use the style for the last character.


Any comments ?

MortenMacFly

Quote from: jens on March 01, 2013, 10:45:42 PM
Any comments ?
No, seems to work here - at lest I see not negative side-effects.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]