Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow single line case if it fits on line #150

Closed
olafurpg opened this issue Apr 13, 2016 · 5 comments · Fixed by #2108
Closed

Allow single line case if it fits on line #150

olafurpg opened this issue Apr 13, 2016 · 5 comments · Fixed by #2108

Comments

@olafurpg
Copy link
Member

From @lihaoyi on Gitter.

How is it that sometimes it puts case (foo, bar) => on a new line, and sometimes it doesn't:

-        .action { (x, c) => c.copy(file = Some(Path(x, cwd))) }
+        .action { (x, c) =>
+          c.copy(file = Some(Path(x, cwd)))
+        }

but

-    val reads = paramSymbols.zip(apply.args).map{ case (param, term) =>
-      val assign = term match{
-        case q"ammonite.repl.ScriptInit.arg($inner)" =>
-
-          val newPrefix = q"ammonite.repl.ScriptInit.parseScriptArg"
-          q"$newPrefix[${param.typeSignature}](${param.name.decoded}, $inner)"
-        case x => x // This case should only be for default args, which we leave unchanged
-      }
-      assign
+    val reads = paramSymbols.zip(apply.args).map {
+      case (param, term) =>
+        val assign = term match {
+          case q"ammonite.repl.ScriptInit.arg($inner)" =>
+            val newPrefix = q"ammonite.repl.ScriptInit.parseScriptArg"
+            q"$newPrefix[${param.typeSignature}](${param.name.decoded}, $inner)"
+          case x =>
+            x // This case should only be for default args, which we leave unchanged
+        }
+        assign
     }
@olafurpg
Copy link
Member Author

For some reason I can't find a solution I'm happy with, I got really deep into issues with the pruneSlowStates optimization until I gave. Saving this issue for a later release, 0.2.1 is already useful as it is.

@olafurpg olafurpg added this to the 0.2.10 milestone Jun 28, 2016
@olafurpg olafurpg modified the milestones: 0.2.14, 0.2.13 Aug 6, 2016
@olafurpg olafurpg removed this from the 0.3.2 milestone Sep 27, 2016
@olafurpg olafurpg added the router label Mar 5, 2017
@tindzk
Copy link

tindzk commented Dec 5, 2017

I think the same rule should apply to the implicit keyword. An example:

DOM.render { implicit ctx =>
  ...
}

Currently, it gets indented as follows:

DOM.render {
  implicit ctx =>
    ...
}

@olafurpg
Copy link
Member Author

Closing as won't fix.

@ches
Copy link
Contributor

ches commented Nov 12, 2018

@olafurpg I thought I recalled seeing a reference to why this is wontfix, maybe it is elsewhere. Was it something hoped that could be addressed through Paiges (or conclusively cannot), or due to Scala 3 potentially not needing the case anyway, or something else?

@olafurpg
Copy link
Member Author

Mostly closed since I don't think it's worth pursuing with the current implementation. A tree printer with paiges should make it easier to support this desirable output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants