| 410 |
410 |
|
// and the reading are one line by construction, and a bar that wrapped
|
| 411 |
411 |
|
// would stop being a bar.
|
| 412 |
412 |
|
let body = match field.kind {
|
| 413 |
|
- |
FieldKind::Textarea => 3,
|
|
413 |
+ |
// Both multi-line kinds get the same three rows, keyed on the
|
|
414 |
+ |
// description's own `multiline` rather than on the member: a markdown
|
|
415 |
+ |
// field falling through to the single-row arm is one line for a value
|
|
416 |
+ |
// whose whole point is that it has several. What a terminal does *with*
|
|
417 |
+ |
// the markdown is another question and the answer here is nothing --
|
|
418 |
+ |
// the source is the text, and drawing it as text is honest.
|
|
419 |
+ |
kind if kind.multiline() => 3,
|
| 414 |
420 |
|
kind if kind.offers_options() => u16::try_from(field.options.len()).unwrap_or(u16::MAX),
|
| 415 |
421 |
|
_ => 1,
|
| 416 |
422 |
|
};
|
| 1021 |
1027 |
|
assert_eq!(rows(&buf)[1], "[ ]");
|
| 1022 |
1028 |
|
}
|
| 1023 |
1029 |
|
|
|
1030 |
+ |
#[test]
|
|
1031 |
+ |
fn a_markdown_field_gets_the_rows_a_textarea_does() {
|
|
1032 |
+ |
// Keyed on `multiline`, so a member added upstream does not silently
|
|
1033 |
+ |
// land on the single-row arm. One row for a value whose whole point is
|
|
1034 |
+ |
// that it has several is the failure this replaced.
|
|
1035 |
+ |
let style = PieceStyle::default();
|
|
1036 |
+ |
let rich = Field::new(FieldKind::Rich, "body", "Body");
|
|
1037 |
+ |
let textarea = Field::new(FieldKind::Textarea, "body", "Body");
|
|
1038 |
+ |
let plain = Field::new(FieldKind::Text, "body", "Body");
|
|
1039 |
+ |
|
|
1040 |
+ |
assert_eq!(
|
|
1041 |
+ |
field_height(&style, &rich, 40),
|
|
1042 |
+ |
field_height(&style, &textarea, 40)
|
|
1043 |
+ |
);
|
|
1044 |
+ |
assert!(field_height(&style, &rich, 40) > field_height(&style, &plain, 40));
|
|
1045 |
+ |
}
|
|
1046 |
+ |
|
| 1024 |
1047 |
|
#[test]
|
| 1025 |
1048 |
|
fn a_tone_and_a_heading_map_without_a_fallback_arm() {
|
| 1026 |
1049 |
|
// Both source enums are closed, which is what lets these be total. A
|