diff --git a/CodeCompletion/CodeFormatter.cs b/CodeCompletion/CodeFormatter.cs index 8e9c9cf97..895db8703 100644 --- a/CodeCompletion/CodeFormatter.cs +++ b/CodeCompletion/CodeFormatter.cs @@ -543,16 +543,18 @@ namespace CodeFormatters if (comm.StartsWith(" ")) { - if (trimed_comm == "then" || trimed_comm == "do") + if (trimed_comm == "then" || trimed_comm == "do" || trimed_comm == "of") { comm = comm.TrimStart(' '); if (comm.Length == 0 || char.IsLetterOrDigit(comm[0]) || add_space_after) comm = " " + comm; } } - if (comm.EndsWith(" ") && (comm.TrimEnd(' ').EndsWith("class") || comm.TrimEnd(' ').EndsWith("static"))) + if (comm.EndsWith(" ")) { - comm = comm.TrimEnd(' ')+" "; + string trimed_end = comm.TrimEnd(' '); + if (trimed_end.EndsWith("class") || trimed_end.EndsWith("static") || trimed_end.EndsWith("else")) + comm = comm.TrimEnd(' ')+" "; } if (comm.Replace(" ","") == "():")//special case: functions with no parameters { @@ -589,6 +591,7 @@ namespace CodeFormatters comm = RemoveOverSpaces(comm); else if (trimed_comm.StartsWith("]") && trimed_comm.EndsWith(":")) comm = comm.Replace(" ", ""); + } WriteCommentWithIndent(comm, true); read_from_beg_pos = false; diff --git a/TestSuite/formatter_tests/input/case7.pas b/TestSuite/formatter_tests/input/case7.pas new file mode 100644 index 000000000..2eb495be1 --- /dev/null +++ b/TestSuite/formatter_tests/input/case7.pas @@ -0,0 +1,7 @@ +begin + case 0 of + 0 .. 1 , 2 .. 3 : exit ; + 4 .. 5 , 6 .. 7 : exit ; + else exit ; + end; +end. \ No newline at end of file diff --git a/TestSuite/formatter_tests/should/case7.pas b/TestSuite/formatter_tests/should/case7.pas new file mode 100644 index 000000000..ac02a19b1 --- /dev/null +++ b/TestSuite/formatter_tests/should/case7.pas @@ -0,0 +1,7 @@ +begin + case 0 of + 0..1, 2..3: exit; + 4..5, 6..7: exit; + else exit; + end; +end. \ No newline at end of file