diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 669f3a3..3e4a763 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -154,8 +154,7 @@ private: { immutable t = tokens[index].type; if (t == tok!"identifier" || isStringLiteral(t) - || isNumberLiteral(t) || t == tok!"characterLiteral" - || isKeyword(t)) + || isNumberLiteral(t) || t == tok!"characterLiteral") write(" "); } } @@ -221,7 +220,7 @@ private: { writeToken(); if (index < tokens.length && (currentIs(tok!"identifier") - || isKeyword(current.type) || isBasicType(current.type) || currentIs(tok!"@"))) + || isBasicType(current.type) || currentIs(tok!"@"))) { write(" "); } @@ -377,7 +376,7 @@ private: newline(); writeToken(); // in/out/body } - else if (peekIsLiteralOrIdent() || peekIsBasicType() || peekIsKeyword()) + else if (peekIsLiteralOrIdent() || peekIsBasicType()) { writeToken(); if (spaceAfterParens || parenDepth > 0) @@ -676,6 +675,8 @@ private: break; case tok!"in": case tok!"is": + if (!peekBackIsOneOf(false, tok!"!", tok!"(", tok!",")) + write(" "); writeToken(); if (!currentIs(tok!"(") && !currentIs(tok!"{")) write(" "); diff --git a/tests/allman/issue0138.d.ref b/tests/allman/issue0138.d.ref new file mode 100644 index 0000000..7dacc3a --- /dev/null +++ b/tests/allman/issue0138.d.ref @@ -0,0 +1,8 @@ +unittest +{ + auto result = a[0] in aa; +} + +void doStuff(in int a, in int b) +{ +} diff --git a/tests/issue0138.d b/tests/issue0138.d new file mode 100644 index 0000000..d976fe6 --- /dev/null +++ b/tests/issue0138.d @@ -0,0 +1,8 @@ +unittest +{ + auto result = a[0] in aa; +} + +void doStuff(in int a, in int b) +{ +} diff --git a/tests/otbs/issue0138.d.ref b/tests/otbs/issue0138.d.ref new file mode 100644 index 0000000..b6abc82 --- /dev/null +++ b/tests/otbs/issue0138.d.ref @@ -0,0 +1,6 @@ +unittest { + auto result = a[0] in aa; +} + +void doStuff(in int a, in int b) { +}