Skip to content

Commit ec698d9

Browse files
committed
Merge pull request #979 from wise0704/ShortcutDialog
Delayed Update for ShortcutDialog
2 parents f92b914 + 1fce456 commit ec698d9

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

FlashDevelop/Dialogs/ShortcutDialog.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace FlashDevelop.Dialogs
1616
{
1717
public class ShortcutDialog : SmartForm
1818
{
19+
private Timer updateTimer;
1920
private ToolStripMenuItem removeShortcut;
2021
private ToolStripMenuItem revertToDefault;
2122
private ToolStripMenuItem revertAllToDefault;
@@ -41,6 +42,7 @@ public ShortcutDialog()
4142
this.InitializeGraphics();
4243
this.PopulateListView("", false);
4344
this.ApplyScaling();
45+
this.SetupUpdateTimer();
4446
}
4547

4648
#region Windows Form Designer Generated Code
@@ -287,8 +289,8 @@ private void PopulateListView(String filter, Boolean viewCustom)
287289
foreach (ShortcutItem item in ShortcutManager.RegisteredItems.Values)
288290
{
289291
if (!this.listView.Items.ContainsKey(item.Id) &&
290-
(item.Id.ToLower().Contains(filter.ToLower()) ||
291-
GetKeysAsString(item.Custom).ToLower().Contains(filter.ToLower())))
292+
(item.Id.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 ||
293+
GetKeysAsString(item.Custom).IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0))
292294
{
293295
if (viewCustom && item.Custom == item.Default) continue;
294296
ListViewItem lvi = new ListViewItem();
@@ -439,14 +441,35 @@ private void ClearFilterClick(Object sender, EventArgs e)
439441
}
440442

441443
/// <summary>
442-
/// Updated the list with the filter
444+
/// Set up the timer for delayed list update with filters.
443445
/// </summary>
444-
private void FilterTextChanged(Object sender, EventArgs e)
446+
private void SetupUpdateTimer()
447+
{
448+
updateTimer = new Timer();
449+
updateTimer.Enabled = false;
450+
updateTimer.Interval = 200;
451+
updateTimer.Tick += UpdateTimer_Tick;
452+
}
453+
454+
/// <summary>
455+
/// Update the list with filter.
456+
/// </summary>
457+
private void UpdateTimer_Tick(Object sender, EventArgs e)
445458
{
459+
updateTimer.Enabled = false;
446460
String searchText = this.filterTextBox.Text.Trim();
447461
this.PopulateListView(searchText, viewCustom.Checked);
448462
}
449463

464+
/// <summary>
465+
/// Restart the timer for updating the list.
466+
/// </summary>
467+
private void FilterTextChanged(Object sender, EventArgs e)
468+
{
469+
updateTimer.Stop();
470+
updateTimer.Start();
471+
}
472+
450473
/// <summary>
451474
/// Closes the shortcut dialog
452475
/// </summary>

0 commit comments

Comments
 (0)