Home
Options

is this 'unindent' behavior By Design or a bug?

edited May 2012
I'd do a 'report bug' except I'm not sure whether I'm doing something un-LINQPad-ish and should be doing things differently :)

Sample code (query window is set to 'C# Statements')

var nums = new[] { 1, 2, 3 }; var query = from x in nums select new { x, SubProperty = from a in nums select new };

I'm doing another anon select inside the property, so my cursor is right after the 'inner' "select new".

I hit enter and the cursor is then on the next line, lined up in the same column as the 'select' right above it.

I then hit { to start the inner properties, but LINQPad 'outdents' it (I'm using spaces and 4 spaces per level, so it removes 4 spaces in front of the {) such that it's now lined up with the 'SubProperty'.

Now, I have a simple enough workaround (just hit Ctrl+Z before continuing) but it feels like LINQPad is doing this intentionally and I'm just not getting why. :)

Sometimes I can get it to happen on the 'outer' anon type as well, although I haven't figured out the pattern to hitting it there just yet.

Comments

  • Options
    edited May 2012
    I can only confirm the behavior you just described. I also did a small test and found out the following:
    • also the first
      select new
      shows this behavior;
    • indenting
      from x in nums
      select new
      one level deeper makes the opening brace unindent two levels, placing the opening brace at the very left column;
    • adding a
      while (true) {
      before
      from x in nums
      select new
      would unindent the opening brace only one level. However, (see next bullet)
    • adding a
      while (true) {}
      before
      from x in nums
      select new
      would unindent the opening brace two levels.
    I guess there's some logic applied that takes into account the number of opening braces compared to the number of closing braces encountered at the point of insertion. I'm afraid the editor's capabilities are not like Visual Studio's or ReSharper's capabilities - which come at a much higher price :-). I personally don't need a perfect outlining tool in LINQPad - I already have VS and ReSharper for that - and I'm quite happy the way LINQPad operates just now. The About box shows that the editor is provided by ActiPro, maybe your question can be answered there.
Sign In or Register to comment.