From 3296f90feb0b8819a56d17907757ec1d9c4450f0 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 21 Oct 2024 16:58:15 +0800 Subject: [PATCH] enhance: only show two chars when they are all ascii letters or digits (#585) --- src/Views/Avatar.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Views/Avatar.cs b/src/Views/Avatar.cs index 71ed204d..c959fa43 100644 --- a/src/Views/Avatar.cs +++ b/src/Views/Avatar.cs @@ -128,10 +128,9 @@ namespace SourceGit.Views foreach (var part in parts) chars.Add(part[0]); - if (chars.Count >= 2) + if (chars.Count >= 2 && char.IsAsciiLetterOrDigit(chars[0]) && char.IsAsciiLetterOrDigit(chars[^1])) return string.Format("{0}{1}", chars[0], chars[^1]); - if (chars.Count == 1) - return string.Format("{0}", chars[0]); + return name.Substring(0, 1); }