@@ -1221,16 +1221,14 @@ let rec extractComments comments tester =
12211221 let open Lexing in
12221222 (* There might be an issue here - we shouldn't have to split "up to and including".
12231223 Up to should be sufficient. Comments' end position might be off by one (too large) *)
1224- comments |> List. partition (fun (str , attLoc , physLoc ) ->
1224+ comments |> List. partition (fun (str , isLineComment , attLoc , physLoc ) ->
12251225 let oneGreaterThanAttachmentLocEnd = attLoc.loc_end.pos_cnum in
12261226 let attachmentLocLastChar = oneGreaterThanAttachmentLocEnd - 1 in
12271227 let oneGreaterThanPhysLocEnd = physLoc.loc_end.pos_cnum in
12281228 let physLastChar = oneGreaterThanPhysLocEnd - 1 in
12291229 tester attLoc.loc_start.pos_cnum attachmentLocLastChar physLoc.loc_start.pos_cnum physLastChar
12301230 )
12311231
1232-
1233-
12341232let space = " "
12351233(* Can't you tell the difference? *)
12361234let tab = " "
@@ -1270,17 +1268,15 @@ let smallestLeadingSpaces strs =
12701268 is part of a list that could potentially break to prevent inline
12711269 comments from being rendered as line comments
12721270*)
1273- let formatItemComment ?(forceMultiline =false ) (str , commLoc , physCommLoc ) =
1271+ let formatItemComment ?(forceMultiline =false ) (str , is_line_comment , commLoc , physCommLoc ) =
12741272 let commLines = Str. split_delim (Str. regexp " \n " ) (" /*" ^ str ^ " */" ) in
1275- match commLines with
1276- | [] -> easyAtom " "
1277- | [hd] ->
1278- if forceMultiline then
1279- makeEasyList ~inline: (true , true ) ~post Space:true ~pre Space:true ~indent: 0 ~break: IfNeed [easyAtom hd]
1280- (* caveat: single line comment . *)
1281- else
1282- makeEasyList ~inline: (true , true ) ~post Space:true ~pre Space:true ~indent: 0 ~break: IfNeed [easyAtom (" //" ^ str)]
1283- | zero ::one ::tl ->
1273+ match (commLines, is_line_comment, forceMultiline) with
1274+ | (_ , true , false ) ->
1275+ makeEasyList ~inline: (true , true ) ~post Space:true ~pre Space:true ~indent: 0 ~break: IfNeed [easyAtom (" //" ^ str)]
1276+ | ([] , _ , _ ) -> easyAtom " "
1277+ | ([hd ], _ , _ ) ->
1278+ makeEasyList ~inline: (true , true ) ~post Space:true ~pre Space:true ~indent: 0 ~break: IfNeed [easyAtom hd]
1279+ | (zero ::one ::tl , _ , _ ) ->
12841280 let lineZero = List. nth commLines 0 in
12851281 let lineOne = List. nth commLines 1 in
12861282 let hasMeaningfulContentOnLineZero = lineZeroHasMeaningfulContent lineZero in
@@ -1321,7 +1317,7 @@ let removeSepFromListConfig listSettings =
13211317 1. Before-line items break in unison with list items.
13221318 2. End of line comments are placed *after* separators. *)
13231319let rec interleaveComments ?endMaxChar listConfig layoutListItems comments =
1324- let isDocComment (c , _ , _ ) = String. length c > 0 && c.[0 ] == '*' in
1320+ let isDocComment (c , _ , _ , _ ) = String. length c > 0 && c.[0 ] == '*' in
13251321 match (layoutListItems, endMaxChar) with
13261322 | ([] , None)-> ([] , comments)
13271323 | ([] , Some endMax )->
0 commit comments