diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d
index cd4ec83..c80b9a1 100644
--- a/src/dfmt/formatter.d
+++ b/src/dfmt/formatter.d
@@ -595,7 +595,8 @@ private:
         }
         else if (index < tokens.length && (currentIs(tok!"@")
                 || isBasicType(tokens[index].type)
-                || currentIs(tok!"identifier") || currentIs(tok!"if")))
+                || currentIs(tok!"identifier") || currentIs(tok!"if"))
+                && !currentIsIndentedTemplateConstraint())
             write(" ");
     }
 
@@ -1021,7 +1022,8 @@ private:
                 else
                 {
                     writeToken();
-                    write(" ");
+                    if (!currentIsIndentedTemplateConstraint())
+                        write(" ");
                 }
             }
             else
@@ -1030,6 +1032,14 @@ private:
         }
     }
 
+    bool currentIsIndentedTemplateConstraint()
+    {
+        return index < tokens.length
+            && astInformation.constraintLocations.canFindIndex(current.index)
+            && (config.dfmt_template_constraint_style == TemplateConstraintStyle.always_newline
+                || currentLineLength >= config.dfmt_soft_max_line_length);
+    }
+
     void formatOperator()
     {
         import std.algorithm : canFind;
diff --git a/tests/allman/issue0248.d.ref b/tests/allman/issue0248.d.ref
new file mode 100644
index 0000000..457d138
--- /dev/null
+++ b/tests/allman/issue0248.d.ref
@@ -0,0 +1,11 @@
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure @things
+        if (Args[$ - 1] != "=")
+{
+
+}
+
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure nothrow
+        if (Args[$ - 1] != "=")
+{
+
+}
diff --git a/tests/issue0248.d b/tests/issue0248.d
new file mode 100644
index 0000000..91f60b7
--- /dev/null
+++ b/tests/issue0248.d
@@ -0,0 +1,11 @@
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure @things
+		if (Args[$ - 1] != "=")
+{
+
+}
+
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure nothrow
+		if (Args[$ - 1] != "=")
+{
+
+}
diff --git a/tests/otbs/issue0248.d.ref b/tests/otbs/issue0248.d.ref
new file mode 100644
index 0000000..1d93ce2
--- /dev/null
+++ b/tests/otbs/issue0248.d.ref
@@ -0,0 +1,9 @@
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure @things
+        if (Args[$ - 1] != "=") {
+
+}
+
+T[] arrayOp(T, Args...)(T res, Filter!(isType, Args) args) @trusted @nogc pure nothrow
+        if (Args[$ - 1] != "=") {
+
+}