News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

[RESOLVED] Source Formatter + Indent Options Woes

Started by AiuaX, April 26, 2012, 03:45:58 AM

Previous topic - Next topic

AiuaX

Though I hope I'm simply overlooking something simple (and please forgive me if I am), I can't help but be stumped by the behavior I'm seeing.

The behavior I'm expecting while writing c++ code in the C::B editor (v 10.05, 32-bit windows 7) is:

  • Moving to a new line within a block of code (i.e. hitting enter) will indent to the same level as the previous line
  • Opening an if/then, switch/case, for block will produce a properly indented block of code (for some definition of properly indented)

The behavior I'm seeing is: When writing c++ code, no indentation is applied to the following structures:

  • classes
  • methods/functions
  • if/else, switch/case, for blocks
  • anything else

My settings are thus (I'll also include screenshots displaying what I see):

  • Auto indent is checked
  • Smart indent is checked
  • Brace completion is checked
  • Source formatter plugin is enabled and set to default (Allman (ANSI))

Disabling the source formatter plugin or resetting C::B preferences does not change the behavior.

Am I simply missing a setting somewhere? I could have sworn this used to work. Am I simply crazy?

[attachment deleted by admin]

Alpha

Quote from: AiuaX on April 26, 2012, 03:45:58 AM
Disabling the source formatter plugin [...]
This plugin is (I think) unrelated to your problem as it is for on-demand formatting of pre-existing code (Right-click->Format use AStyle).

I am not sure what the problem is, but can you try the following?

  • Switch "End-of-line mode" from your current "CR" to "CR LF" (as should be Windows default).
  • Move/delete Code::Blocks' profile (located in %AppData%\CodeBlocks) so that Code::Blocks will regenerate a clean one.
  • If you are feeling adventurous, you could try a nightly (however, your version of Code::Blocks should work).

AiuaX

#2
Fascinating!  Switching to CR+LF did indeed restore things to normal.  I think this must have (maybe, possibly, in theory) happened after bringing a version control system into the equation (configured to auto-convert line-endings on checkout to be platform-specific); or maybe I accidentally rolled my mouse wheel over that Settings field - who knows!

Thank you for the suggestion, Alpha!

Alpha


oBFusCATed

(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!]

Alpha

To reproduce, Settings->Editor... switch "End-of-line mode" to "CR".  Now try typing:

if(true)
{


Normally, this would trigger brace completion such that it becomes (the pipe is the position of the cursor):

if(true)
{
    |
}


However, in "CR" mode, it does not indent:

if(true)
{
|
}