diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eaeb103..69def4e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ the major/minor/patch definitions apply to the application's interface / usage * Added GHC 9.10 support. ### Fixed +* Line truncation `detect` option now subtracts one, so terminals do not add + an extra newline. * More `HasCallStack` annotations for better callstacks in case something goes wrong. * Increase default `--command-log-read-size` to `16 kb` to better prevent diff --git a/src/Shrun/Configuration/Data/Truncation.hs b/src/Shrun/Configuration/Data/Truncation.hs index 117cca95..2e310335 100644 --- a/src/Shrun/Configuration/Data/Truncation.hs +++ b/src/Shrun/Configuration/Data/Truncation.hs @@ -102,6 +102,10 @@ configToLineTrunc :: m (Maybe (Truncation TruncLine)) configToLineTrunc Disabled = pure Nothing configToLineTrunc Without = pure Nothing -configToLineTrunc (With Detected) = Just . MkTruncation <$> getTerminalWidth +configToLineTrunc (With Detected) = + -- We subtract one because otherwise we can fill the entire terminal with a + -- log, which will automatically add a newline. The point of this option is + -- to avoid multiple lines, hence the subtraction. + Just . MkTruncation . (\x -> x - 1) <$> getTerminalWidth configToLineTrunc (With (Undetected x)) = pure $ Just x {-# INLINEABLE configToLineTrunc #-} diff --git a/test/integration/Integration/Miscellaneous.hs b/test/integration/Integration/Miscellaneous.hs index 662bc5c7..d11206e8 100644 --- a/test/integration/Integration/Miscellaneous.hs +++ b/test/integration/Integration/Miscellaneous.hs @@ -234,8 +234,8 @@ lineTruncDetect = testPropertyNamed desc "lineTruncDetect" args = ["-c", getIntConfig "misc", "cmd1"] expected = - [ #coreConfig % #consoleLogging % #lineTrunc % _Just ^?=@ Just 87, - #coreConfig % #fileLogging %? #lineTrunc % _Just ^?=@ Just 87 + [ #coreConfig % #consoleLogging % #lineTrunc % _Just ^?=@ Just 86, + #coreConfig % #fileLogging %? #lineTrunc % _Just ^?=@ Just 86 ] testFileSizeModeNothing :: TestTree