Skip to content

Commit

Permalink
Fix single-line comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdonovan committed Jun 20, 2023
1 parent eb30b90 commit 300fb84
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/src/main/java/org/lflang/ast/FormattingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ static String lineWrapComments(List<String> comments, int width, String singleLi
}
/** Wrap lines. Do not merge lines that start with weird characters. */
private static String lineWrapComment(String comment, int width, String singleLineCommentPrefix) {
if (!MULTILINE_COMMENT.matcher(comment).matches()) return comment;
comment =
comment
.strip()
.replaceAll("^/?((\\*|//|#)\\s*)+", "");
if (!MULTILINE_COMMENT.matcher(comment).matches()) return comment.isBlank() ? "" : singleLineCommentPrefix + " " + comment;
width = Math.max(width, MINIMUM_COMMENT_WIDTH_IN_COLUMNS);
var stripped =
comment
.strip()
.replaceAll("^/?((\\*|//|#)\\s*)+", "")
var stripped = comment
.replaceAll("\\s*\\*/$", "")
.replaceAll("(?<=(\\r\\n|\\r|\\n))\\h*(\\*|//|#)\\h?(\\h*)", "$3");
var preformatted = false;
Expand Down

0 comments on commit 300fb84

Please sign in to comment.