This ends up removing whitespace where it shouldn't. There's other code adding whitespace, e.g. in the mentioned function expression case, but since the linebreak updates usually happen after the whitespace changes, the whitespace is missing at the end.

I tried reordering linebreak and whitespace changes or adding whitespace changes after linebreak changes, but that causes issues in other places again: https://gist.github.com/jzaefferer/c1f34667d3f134e645a6