Skip to content

Commit

Permalink
Delete based on character width when pressing Backspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
TonWin618 authored and patriksvensson committed Aug 1, 2024
1 parent d79e6ad commit bb72b44
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Spectre.Console/Extensions/AnsiConsoleExtensions.Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ internal static async Task<string> ReadLine(this IAnsiConsole console, Style? st
{
if (text.Length > 0)
{
var lastChar = text.Last();
text = text.Substring(0, text.Length - 1);

if (mask != null)
{
console.Write("\b \b");
if (UnicodeCalculator.GetWidth(lastChar) == 1)
{
console.Write("\b \b");
}
else if (UnicodeCalculator.GetWidth(lastChar) == 2)
{
console.Write("\b \b\b \b");
}
}
}

Expand Down

0 comments on commit bb72b44

Please sign in to comment.