Commits

orbitz  committed 96e3d59

Working on handling comments in places other than the end of a line

  • Participants
  • Parent commits 999ea31

Comments (0)

Files changed (2)

File src/formatter.ml

 let incr_src_line state =
   { state with src_line_number = incr state.src_line_number }
 
-let incr_dst_line state =
-  let state = append_line state in
+
+let incr_dst_line_no_append state =
   { state with
     dst_line_number = incr state.dst_line_number;
     builder = Format_builder.add_token state.builder Newline
   }
 
+let incr_dst_line state =
+  incr_dst_line_no_append (append_line state)
+
 
 let (|>) d f = f d
 
        * Toss the ',' back on list
        *)
       ((Keyword ",")::xs)
+  | (Keyword ",")::Newline::Newline::xs ->
+    format_func_list_multiline_inside
+      (state
+	  |> incr_src_line
+	  |> incr_src_line
+	  |> incr_dst_line)
+      ((Keyword ",")::xs)
+  | (Keyword ",")::Newline::(Comment com)::xs ->
+    format_func_list_multiline_inside
+      (state
+	  |> incr_src_line
+	  |> incr_dst_line
+	  |> add_alignment
+	  |> add_token (Comment com))
+      ((Keyword ",")::xs)
+  | (Keyword ",")::Newline::xs ->
+    format_func_list_multiline_inside
+      (state |> incr_src_line)
+      ((Keyword ",")::xs)
   | (Keyword ",")::xs ->
     format_func_list_multiline_inside
       (state

File test_files/test_export.erl

 -export([foo/1,
          foo/2]).
 
+% Forced multiple new lines
+-export([foo/1,
+
+
+         foo/3]).
+
+% With comments
+-export([foo/1, % Does things
+
+
+         % This does other things
+         foo/4
+
+
+         ]).
+
 % With comment
 -export([foo/1, % Does things
          foo/2]).