Skip to content

Commit fbdab5c

Browse files
committed
Add test to ensure it works when double-width and signle-width are mixed
1 parent bb47ac0 commit fbdab5c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: tests/formatter.rs

+28
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,31 @@ fn test_point_to_double_width_characters_multiple() {
645645

646646
assert_eq!(DisplayList::from(snippets).to_string(), expected);
647647
}
648+
649+
#[test]
650+
fn test_point_to_double_width_characters_mixed() {
651+
let snippets = Snippet {
652+
slices: vec![snippet::Slice {
653+
source: "こんにちは、新しいWorld!",
654+
line_start: 1,
655+
origin: Some("<current file>"),
656+
annotations: vec![snippet::SourceAnnotation {
657+
range: (6, 14),
658+
label: "New world",
659+
annotation_type: snippet::AnnotationType::Error,
660+
}],
661+
fold: false,
662+
}],
663+
title: None,
664+
footer: vec![],
665+
opt: Default::default(),
666+
};
667+
668+
let expected = r#" --> <current file>:1:7
669+
|
670+
1 | こんにちは、新しいWorld!
671+
| ^^^^^^^^^^^ New world
672+
|"#;
673+
674+
assert_eq!(DisplayList::from(snippets).to_string(), expected);
675+
}

0 commit comments

Comments
 (0)