summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DisplayWidth.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/DisplayWidth.zig b/src/DisplayWidth.zig
index e547adf..621b8c1 100644
--- a/src/DisplayWidth.zig
+++ b/src/DisplayWidth.zig
@@ -39,6 +39,7 @@ pub fn strWidth(self: Self, str: []const u8) usize {
39 if (cp_iter.next()) |ncp| { 39 if (cp_iter.next()) |ncp| {
40 // emoji text sequence. 40 // emoji text sequence.
41 if (ncp.code == 0xFE0E) w = 1; 41 if (ncp.code == 0xFE0E) w = 1;
42 if (ncp.code == 0xFE0F) w = 2;
42 } 43 }
43 44
44 // Only adding width of first non-zero-width code point. 45 // Only adding width of first non-zero-width code point.
@@ -70,6 +71,9 @@ test "strWidth" {
70 try testing.expectEqual(@as(usize, 2), self.strWidth("\u{26A1}")); // Lone emoji 71 try testing.expectEqual(@as(usize, 2), self.strWidth("\u{26A1}")); // Lone emoji
71 try testing.expectEqual(@as(usize, 1), self.strWidth("\u{26A1}\u{FE0E}")); // Text sequence 72 try testing.expectEqual(@as(usize, 1), self.strWidth("\u{26A1}\u{FE0E}")); // Text sequence
72 try testing.expectEqual(@as(usize, 2), self.strWidth("\u{26A1}\u{FE0F}")); // Presentation sequence 73 try testing.expectEqual(@as(usize, 2), self.strWidth("\u{26A1}\u{FE0F}")); // Presentation sequence
74 try testing.expectEqual(@as(usize, 1), self.strWidth("\u{2764}")); // Default text presentation
75 try testing.expectEqual(@as(usize, 1), self.strWidth("\u{2764}\u{FE0E}")); // Default text presentation with VS15 selector
76 try testing.expectEqual(@as(usize, 2), self.strWidth("\u{2764}\u{FE0F}")); // Default text presentation with VS16 selector
73 try testing.expectEqual(@as(usize, 0), self.strWidth("A\x08")); // Backspace 77 try testing.expectEqual(@as(usize, 0), self.strWidth("A\x08")); // Backspace
74 try testing.expectEqual(@as(usize, 0), self.strWidth("\x7FA")); // DEL 78 try testing.expectEqual(@as(usize, 0), self.strWidth("\x7FA")); // DEL
75 try testing.expectEqual(@as(usize, 0), self.strWidth("\x7FA\x08\x08")); // never less than o 79 try testing.expectEqual(@as(usize, 0), self.strWidth("\x7FA\x08\x08")); // never less than o