#1389 Indentation problems in C and XML

Bug
open-accepted
Neil Hodgson
Scintilla (789)
2
2012-07-17
2012-07-16
Sworddragon
No

I'm using SciTE 3.2.1. In the attachments are 2 example files which are showing indentation problems.

In test.c set the cursor position at the end of line 4. After pressing enter the cursor is below the first for() loop but it should be below the second for() loop.

In test.xml set the cursor position at the end of line 1. After pressing enter there is no indentation but there should be an indentation of 1 tab.

Discussion

  • Sworddragon
    Sworddragon
    2012-07-16

     
    Attachments
  • Sworddragon
    Sworddragon
    2012-07-16

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2012-07-17

    SciTE indentation is quite simple understanding only a limited set of patterns.

    XML indentation is only based on the indentation of the previous line with no increase or decrease based on previous contents.

    The C++ indentation is defeated by the ';' inside the for statement which looks like the end of the statement to the simple indentation code.

    I won't be working on this issue.

     
  • Neil Hodgson
    Neil Hodgson
    2012-07-17

    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 2
    • status: open --> open-accepted
     
  • komal
    komal
    2012-08-22

    Cpp.properties file is reading semicolon as the end of the statement whereas for statement have semicolon in between. So, if we delete the line -

    statement.end.$(file.patterns.c.like)=10 ;

    from cpp.properties, next line after the for statement would get indented.
    This line looks for only one line next to the statement and that is anyways getting indented, so is not required.

     
  • Neil Hodgson
    Neil Hodgson
    2012-08-22

    If the semi-colon is removed from statement.end.$(file.patterns.c.like) then single line compound statements are not handled. There is extra indentation on the line after
    if (!p) vx = dx;

     
  • komal
    komal
    2012-08-22

    Another indentation problem exists for 'case' statement, as case statement should provide indenting for block of statements until break, continue or return statement is encountered instead of single statement.

    We can create a block for 'case' statement by adding following lines in cpp.properties

    block.start.$(file.patterns.c.like) =5 case default
    block.end.$(file.patterns.c.like)=5 break continue return

    But these statements conflicts with originally present block statement for braces--

    block.start.$(file.patterns.c.like) =10 {
    block.end.$(file.patterns.c.like)=10 }

    Is there any way to merge these statements??

     
  • komal
    komal
    2012-08-22

    if(!p) vx=dx;

    can be written as :
    if (!p)
    vx = dx;

    This won't give extra indentation and is also more readable.

     
  • Neil Hodgson
    Neil Hodgson
    2012-08-23

    I can't see any way to improve switch/case using the current implementation.