https://bugs.kde.org/show_bug.cgi?id=360456

            Bug ID: 360456
           Summary: Pointer assignment after closed C comment incorrectly
                    triggers autostar
           Product: kate
           Version: unspecified
          Platform: Debian stable
                OS: Linux
            Status: UNCONFIRMED
          Severity: minor
          Priority: NOR
         Component: indentation
          Assignee: kwrite-bugs-n...@kde.org
          Reporter: louisw...@fastmail.fm

The logic which provides automatic indentation for C code being edited in both
Kate and KWrite features the capability to "autostar" (automatically start new
lines with an asterisk and appropriate whitespace) when it detects that the
region being edited is within a comment. For example, given the following C
code:

/* This is a comment
 * This is where the cursor is/was positioned ->

then, after pressing the Return/Enter key on the keyboard, the indenter
automatically adds an asterisk to the next line:

/* This is a comment
 * This is where the cursor is/was positioned ->
 *

This is a very useful feature. However, it can become confused when a closed
C-style comment is followed by a pointer assignment. See the steps to
reproduce, actual results, and expected results for an example.

Reproducible: Always

Steps to Reproduce:
1. Open a new document in Kate (although this also happens in KWrite)
2. Save the document as "test.c" to indicate that this is a C source file
3. Within the document, type the following syntactically-valid C code:

    int *test;
    /* Here, we assign a value to the pointee object */
    *test = 42;

4. Position the cursor immediately after the semicolon which terminates the
final line (the assignment).
5. Press the Enter/Return key.

Actual Results:  
The new line is automatically indented, as expected, but an asterisk is added
as though we are currently in a C comment, which is incorrect:

    int *test;
    /* Here, we assign a value to the pointee object */
    *test = 42;
    *

Expected Results:  
The new line should have automatically been indented, but no asterisk should
have been added because the comment was already closed:

    int *test;
    /* Here, we assign a value to the pointee object */
    *test = 42;
    {note that this line is blank, but see the indentation to the left}

I assume that this is not a wishlist item, because it is technically incorrect
behavior. However, there is most certainly an easy workaround (i.e., delete the
asterisk). Honestly, this "bug" doesn't "bug" me and I expect very few people
will ever even run into it -- I'm just trying to do my part as an open source
citizen by reporting the unexpected behavior. I would be happy to provide more
information if required.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to