Permalink
Browse files

[skip ci] fix errors at deleting words

  • Loading branch information...
nopara73 committed Nov 8, 2018
1 parent afe735e commit a31eeab86027895c9ccabe6d13be212ad1098e09
Showing with 17 additions and 7 deletions.
  1. +17 −7 WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletViewModel.cs
@@ -87,7 +87,7 @@ public RecoverWalletViewModel(WalletManagerViewModel owner) : base("Recover Wall
this.WhenAnyValue(x => x.CaretIndex).Subscribe(_ =>
{
if(CaretIndex != MnemonicWords.Length)
if (CaretIndex != MnemonicWords.Length)
{
CaretIndex = MnemonicWords.Length;
}
@@ -137,7 +137,7 @@ public int CaretIndex
get { return _caretIndex; }
set { this.RaiseAndSetIfChanged(ref _caretIndex, value); }
}
public ReactiveCommand RecoverCommand { get; }
public void OnTermsClicked()
@@ -168,8 +168,11 @@ public override void OnCategorySelected()
private void UpdateSuggestions(string words)
{
if (string.IsNullOrEmpty(words))
if (string.IsNullOrWhiteSpace(words))
{
Suggestions?.Clear();
return;
}
string[] enteredWordList = words.Split(' ', StringSplitOptions.RemoveEmptyEntries);
var lastWorld = enteredWordList.LastOrDefault().Replace("\t", "");
@@ -180,10 +183,10 @@ private void UpdateSuggestions(string words)
return;
}
var suggestedWords = EnglishWords.Where(w => w.StartsWith(lastWorld));
var suggestedWords = EnglishWords.Where(w => w.StartsWith(lastWorld)).Take(7);
_suggestions.Clear();
foreach(var suggestion in suggestedWords)
foreach (var suggestion in suggestedWords)
{
_suggestions.Add(new MnemonicViewModel(suggestion, OnAddWord));
}
@@ -192,8 +195,15 @@ private void UpdateSuggestions(string words)
public void OnAddWord(string word)
{
string[] words = MnemonicWords.Split(' ', StringSplitOptions.RemoveEmptyEntries);
words[words.Length-1] = word;
MnemonicWords = string.Join(' ', words) + " ";
if (words.Length == 0)
{
MnemonicWords = word + " ";
}
else
{
words[words.Length - 1] = word;
MnemonicWords = string.Join(' ', words) + " ";
}
CaretIndex = MnemonicWords.Length;

0 comments on commit a31eeab

Please sign in to comment.