Skip to content

Commit

Permalink
Router: skip shebang line, allow top-level if used
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 28, 2022
1 parent b12c9fb commit 753e3b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object Scalafmt {
): Formatted.Result = {
def getStyleByFile(style: ScalafmtConfig) = {
val isSbt = FileOps.isAmmonite(filename) || FileOps.isSbt(filename) ||
FileOps.isMarkdown(filename)
FileOps.isMarkdown(filename) || code.startsWith("#!")
if (isSbt) style.forSbt else style
}
val styleTry =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class Router(formatOps: FormatOps) {
Seq(Split(NoSplit.orNL(next(ft).right.is[T.EOF]), 0))
case FormatToken(_: T.BOF, right, _) =>
val policy = right match {
case T.Ident(name) // shebang in .sc files
if FileOps.isAmmonite(filename) && name.startsWith("#!") =>
case T.Ident(name) if name.startsWith("#!") =>
val nl = findFirst(next(formatToken), Int.MaxValue) { x =>
x.hasBreak || x.right.is[T.EOF]
}
Expand Down

0 comments on commit 753e3b0

Please sign in to comment.