Fix the command is cleared after repeated

This commit is contained in:
2023-01-12 14:22:40 +08:00
parent 2dc8dc734b
commit f4fc0ef3c5

View File

@ -208,12 +208,11 @@ namespace GrasscutterTools.Forms
{ {
Logger.I(TAG, $"SetCommand(\"{command}\")"); Logger.I(TAG, $"SetCommand(\"{command}\")");
var oldCommand = CmbCommand.Text; var oldCommand = CmbCommand.Text;
CmbCommand.Text = (ModifierKeys == Keys.Shift) ? if (ModifierKeys == Keys.Shift && !string.IsNullOrEmpty(oldCommand))
(string.IsNullOrEmpty(oldCommand) ? command : $"{oldCommand} | {command}") command = $"{oldCommand} | {command}";
: command; AddCommandToList(command);
if (ChkAutoCopy.Checked) if (ChkAutoCopy.Checked)
CopyCommand(); CopyCommand();
AddCommandToList(command);
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
{ {
@ -233,12 +232,12 @@ namespace GrasscutterTools.Forms
{ {
if (string.IsNullOrEmpty(command)) if (string.IsNullOrEmpty(command))
command = CmbCommand.Text; command = CmbCommand.Text;
if (!string.IsNullOrEmpty(command)) if (string.IsNullOrEmpty(command))
{ return;
if (CmbCommand.Items.Count > 19) if (CmbCommand.Items.Count > 19)
CmbCommand.Items.RemoveAt(0); CmbCommand.Items.RemoveAt(0);
CmbCommand.Items.Add(command); CmbCommand.Items.Add(command);
} CmbCommand.SelectedIndex = CmbCommand.Items.Count - 1;
} }
/// <summary> /// <summary>