This commit is contained in:
2026-05-27 11:08:50 +02:00
parent a2d0ca3ce4
commit 7928ec6f20
2 changed files with 32 additions and 38 deletions

View File

@@ -70,30 +70,6 @@ namespace BeWo.ViewModel.Controls.AI
FirePropertyChanged(nameof(IsUndoButtonVisible));
}
public void Accept(string str)
{
var idx = CurrentIndex;
var count = History.Count;
var last_idx = count - 1;
if (last_idx > idx)
{
History.RemoveRange(idx + 1, last_idx - idx);
}
if (CurrentValue != History[CurrentIndex])
{
History.Add(CurrentValue);
CurrentIndex++;
}
History.Add(str);
CurrentIndex++;
CurrentValue = str;
}
public void UndoAiAction()
{
if (CurrentIndex <= 0)
@@ -124,12 +100,36 @@ namespace BeWo.ViewModel.Controls.AI
var str = sb.ToString();
Accept(str);
accept(str);
}
public void ReplaceValue(string str)
{
Accept(str);
accept(str);
}
private void accept(string str)
{
var idx = CurrentIndex;
var count = History.Count;
var last_idx = count - 1;
if (last_idx > idx)
{
History.RemoveRange(idx + 1, last_idx - idx);
}
if (CurrentValue != History[CurrentIndex])
{
History.Add(CurrentValue);
CurrentIndex++;
}
History.Add(str);
CurrentIndex++;
CurrentValue = str;
}
}
}