Conversation

fhammerschmidt

This PR is an alternative to #6387
Fixes #6380

@fhammerschmidt

Found out that it did not break correctly if the newline was before the last pipe (no matter how many pipes there were in total). Fixed now.
Also moved all smart pipe tests to a separate file.
Also added a formatting test with a React Hook which is now more densely formatted (the same as when there was a {} block in it).

@fhammerschmidt

I formatted a big codebase with this change and the only thing that changed were some Hooks like this one:

-  React.useCallback(
-    () =>
-      flatListRef.current
-      ->Nullable.toOption
-      ->Option.forEach(flatList => flatList->FlatList.scrollToOffset({offset: 0.})),
-    [],
-  )
+  React.useCallback(() =>
+    flatListRef.current
+    ->Nullable.toOption
+    ->Option.forEach(flatList => flatList->FlatList.scrollToOffset({offset: 0.}))
+  , [])

However, if you wrapped the former callback body in curly braces it was already formatted like that:

  React.useCallback(() => {
    flatListRef.current
    ->Nullable.toOption
    ->Option.forEach(flatList => flatList->FlatList.scrollToOffset({offset: 0.}))
  }, [])

If this change is ok, the PR is ready to review
@zth @cristianoc @cknitt

@zth

Looks great to me! @cristianoc ?

@cristianoc

Looks great to me! @cristianoc ?

Looks great

@zth

@fhammerschmidt fix that merge conflict and then let's merge? This is really worthy of a forum post as well given this is something many have complained about over the years. Great work! ⭐

@zthzth merged commit 843e2fc into rescript-lang:master Sep 27, 2023
@fhammerschmidtfhammerschmidt deleted the smart-pipe-printer branch September 27, 2023 07:13
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Smart linebreak printer for pipe chains