@@ -932,9 +932,8 @@ defmodule Code do
932
932
933
933
## Code comments
934
934
935
- The formatter also handles code comments in a way to guarantee a space
936
- is always added between the beginning of the comment (#) and the next
937
- character.
935
+ The formatter handles code comments and guarantees a space is always added
936
+ between the beginning of the comment (#) and the next character.
938
937
939
938
The formatter also extracts all trailing comments to their previous line.
940
939
For example, the code below
@@ -946,9 +945,19 @@ defmodule Code do
946
945
# world
947
946
hello
948
947
949
- Because code comments are handled apart from the code representation (AST),
950
- there are some situations where code comments are seen as ambiguous by the
951
- code formatter. For example, the comment in the anonymous function below
948
+ While the formatter attempts to preserve comments in most situations,
949
+ that's not always possible, because code comments are handled apart from
950
+ the code representation (AST). While the formatter can preserve code
951
+ comments between expressions and function arguments, the formatter
952
+ cannot currently preserve them around operators. For example, the following
953
+ code will move the code comments to before the operator usage:
954
+
955
+ foo() ||
956
+ # also check for bar
957
+ bar()
958
+
959
+ In some situations, code comments can be seen as ambiguous by the formatter.
960
+ For example, the comment in the anonymous function below
952
961
953
962
fn
954
963
arg1 ->
0 commit comments