Menu

#1604 CPP, editor, wrong cursor position after [return] in comments

Undefined
fixed
nobody
None
Bug_Report
2026-07-24
2026-06-01
Elena
No

IMPORTANT PREMISE: I apologize in advance, this is inherent to SNV 13620, I know it's oldish. Unfortunately Sourceforge is more than often very slow or offline from my area in Italy (not clear why), so I am not updating very often anymore as I did in the past. However, chances are this bug was never reported (I tried searching for similar existing tickets to no avail, again, my apologies if I missed it)

The bug shows up in text editor, in cpp files, in multi-line comments between /* */ despite sometimes I also noticed it in multi-line comments starting with //.
What happens is that, at random (impossible to replicate), when I press [return] to terminate a line, the cursor on the next line gets placed NOT at beginning, as it should be, but at a random advanced position thru the new line.

With some efforts, I managed to collect an example .cpp which always shows the bug (attached).
There, if you place the cursor after the dot in the last line "never be adjusted)." and press [return], the cursor on the new line is placed far away, about under the word "value" above, instead of being placed at the beginning of the new line.

Hope this helps, thanks in advance.

1 Attachments

Discussion

  • Christo

    Christo - 2026-07-05

    Issue is easily reproducible by the steps provided. Issue is caused by smartindentcpp plugin.
    The plugin does smart indent without checking if it is comment. Disabling smartindent for comments can solve this issue. I'm not sure if this breaks anything else.

    --- a/src/plugins/contrib/SmartIndent/SmartIndentCpp.cpp
    +++ b/src/plugins/contrib/SmartIndent/SmartIndentCpp.cpp
    @@ -86,6 +86,12 @@ void SmartIndentCpp::DoSmartIndent(cbEditor* ed, const wxChar &ch)const
             return;
    
         const int pos = stc->GetCurrentPos();
    
    +    const int style = stc->GetStyleAt(pos);
    +    if (stc->IsComment(style))
    +    {
    +        fprintf(stderr, "[SmartIndent] %s:%d no smart indent in comments\n", __FUNCTION__, __LINE__);
    +        return;
    +    }
         // indent
         if ( (ch == _T('\n')) || ( (stc->GetEOLMode() == wxSCI_EOL_CR) && (ch == _T('\r')) ) )
         {
    
     
  • Miguel Gimenez

    Miguel Gimenez - 2026-07-06

    IMHO the fprintf() is not needed, it will just generate noise for an otherwise valid condition.

     
    👍
    2
  • Miguel Gimenez

    Miguel Gimenez - 2026-07-24
    • status: open --> fixed
     
  • Miguel Gimenez

    Miguel Gimenez - 2026-07-24

    Fixed in [r13921].

     

    Related

    Commit: [r13921]


Log in to post a comment.