mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Format shebangs correctly
Fixes the regression I described in [#1135]. [#1135]: https://github.com/roc-lang/roc/issues/1135
This commit is contained in:
parent
a55be77509
commit
d678f1c049
1 changed files with 8 additions and 0 deletions
|
@ -149,6 +149,14 @@ pub fn fmt_comments_only<'a, 'buf, I>(
|
|||
}
|
||||
|
||||
fn fmt_comment(buf: &mut Buf, comment: &str) {
|
||||
// Format shebangs without whitespace. We look for " !" as well to fix incorrect formatting from
|
||||
// the past.
|
||||
if buf.is_empty() && (comment.starts_with('!') || comment.starts_with(" !")) {
|
||||
buf.push('#');
|
||||
buf.push_str(comment.trim());
|
||||
return;
|
||||
}
|
||||
|
||||
// The '#' in a comment should always be preceded by a newline or a space,
|
||||
// unless it's the very beginning of the buffer.
|
||||
if !buf.is_empty() && !buf.ends_with_space() && !buf.ends_with_newline() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue