diff --git a/src/string_width.gleam b/src/string_width.gleam --- a/src/string_width.gleam +++ b/src/string_width.gleam @@ -1192,6 +1192,9 @@ /// ### Examples /// /// ```gleam +/// align("", to: 5, align: Left, with: "x") +/// // --> "xxxxx" +/// /// align("hello", to: 10, align: Left, with: " ") /// // --> "hello " /// @@ -1236,7 +1239,9 @@ let space_width = spacer_width(options, space) let str_size = dimensions_with(str, options) - let bottom = str_size.rows + // in contrast to other view functions, we want to treat empty strings + // as empty lines, not empty blocks here. hence int.max(1, _) + let bottom = int.max(1, str_size.rows) let right = int.max(str_size.columns, max_width) use line, line_width <- view(str, 0, 0, options, bottom:, right:)