Closed etcimon closed 10 years ago
Well, although in my mind if you write such code, you shouldn't be coding, I will agree that this is a bug :P
Well, although in my mind if you write such code, you shouldn't be coding, I will agree that this is a bug :P
Nah I refactored this to
foreach(field; fields) ret ~= data.get(field, string.init);
Looks much better =)
Do you know how this could be done with std.algorithm.map?
While we're into indentation, it would be great (imo) if every new line without semi-colon would align to the last dot
e.g.
auto ret = m_data.keys
.map!(k => match(k, r)? k : string.init)
.filter!("a.length > 0")
.array;
would become:
auto ret = m_data.keys
.map!(k => match(k, r)? k : string.init)
.filter!("a.length > 0")
.array;
btw I got this error while pressing tab aka aligning it properly:
System.ArgumentOutOfRangeException: must be <= charArrayLength (116) was :4294967236
Parameter name: textIndex
at Mono.TextEditor.TextViewMargin.TranslateToUTF8Index(Char[] charArray, UInt32 textIndex, UInt32& curIndex, UInt32& byteIndex)
at Mono.TextEditor.TextViewMargin.<>cDisplayClass15.
Are there other cases than if else if to pay attention on?
Basically everything seems out of order for bracketless statements
if (something)
foreach(something)
for(;;)
if ()
else
woop;
wat?
Are there other cases than if else if to pay attention on?
Also the switch cases!
final switch(arr.front){
case "key1":
writeln("woot");
break;
case "
should return to the "case" indentation after break; goto; return; continue; (maybe others), as long as it comes from base indentation (not in an if/while/for/foreach/function/etc)
The behavior for bracketless indentation positions that I'd expect is, they should just fall back to the last if's indentation by default after a semi-colon or a bracket closure, and every time you press enter it should fall back to the previous if's indentation (without skipping a line), until it falls down to the last bracket identation.
I'd be happy if you factored in the period-indentation behavior (when the line is a statement that ends without a semicolon, adjust to the last period)
Thanks! Did you check the switch/case?
well it's actually formatting this kinda stuff as soon as you type a colon ':' - but I guess I could hack a special case for 'case' in there as well.
Well, I can't think of any situation when break; continue; goto *; return *;
won't go back an indent tick if followed by a line break, it could be good to apply it.
Formatting the line when the semicolon is typed is the right way to do it, because it is valid for functions that don't return to be the last statement in a case (provided I remember right anyways), and that also precludes any other random ways that people can find to end a case. Formatting immediately after typing the case token would still be appropriate, although inconsistent with C#.
Formatting immediately after typing the case token would still be appropriate, although inconsistent with C#.
I would think it's a bonus if you can predict what comes next?
Well, I can't think of any situation when break; continue; goto ; return ; won't go back an indent tick if followed by a line break, it could be good to apply it.
Here's an illustration of what I mean
switch (test){
case 1:
dosomething();
break;
^ cursor goes here
When writing:
The identation starting at else is wrong it should be: