Monodevelop annoying auto indentation

I’ve started working with MD 4.0.1

Indentation became a big problem for me. When a just press ENTER and move to the new line MD adds one more tab to the beginning of the line. So after every ENTER pressing I need to press BACKSPACE.

I changed indentation mode from Smart to Automatic at [Tools → Text Editor → Behavior → Indentation mode]. This solved problem with ENTER.

But Monodevelop still more “smart” than me! When I paste in any position in the line MD adds one more tab to the beginning of the line. So after evert Ctrl+V pressing I need to press Ctrl+Z.

Does anyone else have this problem?

3 Likes

Yes, and this is making me crazy !
I tried modifying policies to force indentation to act as I wish, but the indent-on-paste behavior seems to be impossible to override…
And no matter what indentation style I set (none, auto or smart (auto is dumb and smart is auto+smart :face_with_spiral_eyes:)) :sad: !

Anybody here with a solution for this ?

2 Likes

Bump. Same for me :frowning:

Oh thank havens, I’m not the only person that noticed this. Yes, if anyone has a work around would be great.

Has anyone submitted this to the issue tracker?

1 Like

ahaa!

for me it happens when namespace block was not indented,
so auto-intend was actually correctly trying to add the extra tab…

I’ve noticed it as well, what works for me is typing escape before hitting enter. Pain in the neck

that doesn’t seem to work for me. i love the new autocomplete and the method structure outline look, and zooming text is great for my older eyes but i wish improvements like this didn’t have to come at the expense of extra unwanted indenting. frustrating…it does two tab spaces to the right when i hit Enter on any line. BTW on a Mac ML10.8, Unity 4.2.1 but using the new MonoDevelop.

So I’m not exactly noob, there’s something wrong with the tool?

Same problem here! Using Unity 4.3.1 on windows 8.1. Auto indentation is out of order! :slight_smile:
Can anyone confirm if it’s fixed in Unity 4.3.2? This is embarrassing really. Indentation worked much better on previous versions of MonoDevelop and now it’s broken. :frowning:

Ok I seemed to have found a fix (that at least worked for me) for the wacky indentation problem.
First thing that I did was to start Unity in Administrator mode (talking about Windows 8.1). Don’t know why but this seems to make Unity and MonoDevelop behave better overall.
Then…
The following steps apply for the windows version of Unity built-in MonoDevelop:

  1. Start MonoDevelop and go to Tools → Options
  2. In the left side menus scroll down to the “Code Formatting” menu and click it
  3. In the right side options you will see a row with: “C# source code” and on the “Policy” column you should see “Custom”. Click on that “Custom” field and select “Microsoft Visual Studio” from the drop-down menu.

After this indentation and auto-completion seems to be golden in Unity 4.3.1 MonoDevelop (on Windows 8.1).

Hope this helps anyone.

6 Likes

Still no luck here. I’ve tried your solution, but within namespace block the problem still preserves.

But does it fix indentation issues for all other scenarios without using namespaces? Or nothing changed for you with the suggested fix.

My specific problem may be described in that way:
I’m used to not to indent namespace block, because nearly all of my code lies within namespace blocks and this is a waste of space imo. So my code looks like this:

namespace Something {

class Anything {
    public Anything() {} // normal indent rules here
}

} // namespace

MonoDevelop 4.0.1 problem is that it ignores custom indent rules for namespaces (I don’t know about other blocks), and when pasting anything inside namespace block (no matter where, it may be inside if, while, method, etc) it always will add one extra indent.

I cloned Unity MonoDevelop branch the other day and I wanted to find out where’s the code responsible for this behavior, but still I didn’t have the time to do so.

Oh now I understand! :slight_smile: Don’t know about custom indentation rules.
It adds the extra indent because he applies normal indentation and because of the existence of the namespace bracket “{” he will add one
extra indent for everything else.
Give us a buzz back on this thread if you do manage to find a way to customize this.

This is EXACTLY my situation. Let us know if you find a fix!

Kind of related/unrelated, but on Mac, does anybody else have problems with MonoDevelop slowing to a crawl after about half an hour of coding, so you have to save, close the program, and then restart it to get it back up to speed?

Feels like a memory leak is occurring somewhere in it. And yes, the auto-indentation is driving me NUTS!

Yes! I’ve seen that… also the problem where when you open a file via Unity, sometimes MonoDevelop will demand to reload the entire program.

It’s a shame the current version has so many issues, I actually quite like MonoDevelop as an IDE.

At the moment though, does anybody have any replacement IDE’s? Just curious, I’m probably still going to use MD, but if there is an alternative, I’d be glad to hear it!

Just for the record: I’ve found that in the CSharpTextEditorIndetiation file in HandleTextPaste() method there is a line that looks like this:

string newIndent = stateTracker.Engine.ThisLineIndent;

This particular line is used in one more place: when Smart indent is turned on. This simply means that pasting code triggers similar behavior to using Smart indent (which is behaving wrong).

StateTracker is using CSharpIndentEngine and it counts blocks to determine the indent depth, but it has no reference to formatting rules (so it ignores namespace indent rule). I may be wrong, but it looks like somebody changed how indentation should work in the new MonoDevelop, and there’s now 2 ways for doing the same thing.

Now I will try to build MonoDevelop on Windows, but it may take several days because of lack of time.

is there a way to revert to the older version of monodevelop and use the current Unity?