Repository: ErykMroczek/mofmt (language: python)

Issue:
Unnecessary whitespace for selective model extension
The selective model extension, which mofmt supports since #6, is not formatted correct.

This code:
```
model NewPlant
  extends System(
    break controller,
    break reference);
end NewPlant;
```

Is formatted as:
```
model NewPlant

  extends System(
    break controller ,
    break reference );

end NewPlant;
```

Note the extra white spaces at the end of each break statement.


Discussion / hints:

Fix patch:
diff --git a/src/formatting.rs b/src/formatting.rs
index d89f491..e404a53 100644
--- a/src/formatting.rs
+++ b/src/formatting.rs
@@ -805,8 +805,11 @@ fn inheritance_modification(f: &mut Formatter, tree: Tree) {
         match child {
             Child::Tree(tree) => connect_equation(f, tree),
             Child::Token(tok) => {
+                let kind = tok.kind;
                 f.handle_token(tok);
-                f.markers.push(Marker::Space);
+                if kind == ModelicaToken::Break {
+                    f.markers.push(Marker::Space);
+                }
             }
         }
     }
diff --git a/src/lib.rs b/src/lib.rs
index d7fde03..c73703b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,8 +17,8 @@ mod tree;
 
 mod tests {
 
-    use moparse::{parse, ModelicaToken, SyntaxKind};
     use super::*;
+    use moparse::{parse, SyntaxKind};
 
     fn format_code(input: &str, entry: SyntaxKind) -> String {
         let parsed = parse("", input, entry);
@@ -31,7 +31,9 @@ mod tests {
         let source = "x+2   * (  - y)";
         let expected = "x + 2 * (-y)";
         let actual = format_code(source, SyntaxKind::SimpleExpression);
-        assert_eq!(expected, actual, "expected that operators are surrouned with spaces");
+        assert_eq!(
+            expected, actual,
+            "expected that operators are surrouned with spaces"
+        );
     }
-
 }


Test patch:
diff --git a/tests/samples/code-input.mo b/tests/samples/code-input.mo
index 41b22eb..363e310 100644
--- a/tests/samples/code-input.mo
+++ b/tests/samples/code-input.mo
@@ -40,7 +40,7 @@ end 'Quoted record "whatever"';
 
 final partial model FooModel
       "Foo model"
-     extends .Bark.Bark(break connect(a.b  ,c),
+     extends .Bark.Bark(break connect(a.b  ,c),break Baz,
      anotherUselessVar = break);
 
 // Some conditional expressions
diff --git a/tests/samples/code-output.mo b/tests/samples/code-output.mo
index 9263280..b0540db 100644
--- a/tests/samples/code-output.mo
+++ b/tests/samples/code-output.mo
@@ -47,6 +47,7 @@ final partial model FooModel
 
   extends .Bark.Bark(
     break connect(a.b, c),
+    break Baz,
     anotherUselessVar = break);
 
   // Some conditional expressions