Skip to content
This repository has been archived by the owner on Nov 8, 2017. It is now read-only.

Commit

Permalink
Pedantic little change, but checking the count of the passbits stack …
Browse files Browse the repository at this point in the history
…is more than 0 prevents program from crashing if you press backspace too many times.
  • Loading branch information
PromoFaux committed Jul 11, 2014
1 parent 7bdf317 commit ed441ed
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions TestRedditSharp/Program.cs
Expand Up @@ -82,12 +82,15 @@ public static string ReadPassword()
for (ConsoleKeyInfo cki = Console.ReadKey(true); cki.Key != ConsoleKey.Enter; cki = Console.ReadKey(true))
{
if (cki.Key == ConsoleKey.Backspace)
{
//rollback the cursor and write a space so it looks backspaced to the user
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
Console.Write(" ");
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
passbits.Pop();
{
if (passbits.Count() > 0)
{
//rollback the cursor and write a space so it looks backspaced to the user
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
Console.Write(" ");
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
passbits.Pop();
}
}
else
{
Expand Down

0 comments on commit ed441ed

Please sign in to comment.