Skip to content

Commit

Permalink
🩹 Fix the None type not being bolded
Browse files Browse the repository at this point in the history
  • Loading branch information
MystPi committed Apr 6, 2024
1 parent ab1a586 commit 7cfeafd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- The `None` type not being bolded

## v1.0.1 - 2024-04-06

### Fixed
Expand All @@ -15,4 +19,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v1.0.0 - 2024-03-05

- Initital released
- Initital released
15 changes: 15 additions & 0 deletions birdie_snapshots/data_is_styled_depending_on_its_type.new
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
version: 1.0.4
title: data is styled depending on its type
---
#(
Ok(1234),
"blah",
True,
Nil,
None,
//fn(a) { ... },
3.14,
"A",
Foo(1, "2", "3"),
)
5 changes: 3 additions & 2 deletions src/pprint.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ fn pretty_custom_type(
}
})

let open = doc.concat([ansi(name, style, config), doc.from_string("(")])
let name = ansi(name, style, config)
let open = doc.concat([name, doc.from_string("(")])
let close = doc.from_string(")")

case fields {
[] -> doc.from_string(name)
[] -> name
// If the constructor has only one field, it is formatted without indenting
// its field to improve readability. In other words, it is formatted like this
//
Expand Down
13 changes: 12 additions & 1 deletion test/pprint_test.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gleam/dict
import gleam/dynamic
import gleam/option.{None}
import gleeunit
import gleeunit/should
import birdie
Expand Down Expand Up @@ -47,7 +48,17 @@ pub fn complex_data_test() {
}

pub fn coloring_test() {
#(Ok(1234), "blah", True, Nil, fn(a) { a }, 3.14, <<65>>, Foo(1, "2", "3"))
#(
Ok(1234),
"blah",
True,
Nil,
None,
fn(a) { a },
3.14,
<<65>>,
Foo(1, "2", "3"),
)
|> pprint.styled
|> birdie.snap("data is styled depending on its type")
}
Expand Down

0 comments on commit 7cfeafd

Please sign in to comment.