Skip to content

Commit 4a6af87

Browse files
committed
Merge branch 'Shortcuts' into ShortcutDialog
2 parents 9ae8aff + 4997d5d commit 4a6af87

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

FlashDevelop/Dialogs/ShortcutDialog.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ShortcutDialog : SmartForm
1616
{
1717
const string ViewConflictsKey = "?"; // TODO: Change the type to char after #969 is merged
1818
const string ViewCustomKey = "*"; // TODO: Change the type to char after #969 is merged
19-
19+
2020
Timer updateTimer;
2121
ToolStripMenuItem removeShortcut;
2222
ToolStripMenuItem revertToDefault;
@@ -203,7 +203,7 @@ private void InitializeComponent()
203203
this.ResumeLayout(false);
204204
this.PerformLayout();
205205
}
206-
206+
207207
#endregion
208208

209209
#region Methods And Event Handlers
@@ -262,7 +262,7 @@ void ApplyScaling()
262262
this.idHeader.Width = ScaleHelper.Scale(this.idHeader.Width);
263263
this.keyHeader.Width = ScaleHelper.Scale(this.keyHeader.Width);
264264
}
265-
265+
266266
/// <summary>
267267
/// Updates the font highlight of the item.
268268
/// </summary>
@@ -331,7 +331,7 @@ void PopulateListView(string filter)
331331
{
332332
var item = this.shortcutListItems[i];
333333
if (string.IsNullOrEmpty(filter) ||
334-
item.Id.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 ||
334+
item.Id.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 ||
335335
item.KeysString.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
336336
{
337337
if (viewCustom && !item.IsModified) continue;
@@ -413,10 +413,11 @@ void AssignNewShortcut(ShortcutListItem item, Keys shortcut)
413413
else if (!ToolStripManager.IsValidShortcut(shortcut)) return;
414414

415415
if (item.Custom == shortcut) return;
416+
this.listView.BeginUpdate();
416417
item.Custom = shortcut;
417418
item.Selected = true;
418-
ResetConflicts(item);
419419
this.GetConflictItems(item);
420+
this.listView.EndUpdate();
420421
if (item.HasConflicts)
421422
{
422423
ErrorManager.ShowWarning(TextHelper.GetString("Info.ShortcutIsAlreadyUsed"), null);
@@ -425,7 +426,7 @@ void AssignNewShortcut(ShortcutListItem item, Keys shortcut)
425426
this.filterTextBox.SelectAll();
426427
}
427428
}
428-
429+
429430
/// <summary>
430431
/// Resets the conflicts status of an item.
431432
/// </summary>
@@ -443,7 +444,7 @@ static void ResetConflicts(ShortcutListItem item)
443444
item.Conflicts = null; // empty conflicts list will be garbage collected
444445
}
445446
}
446-
447+
447448
/// <summary>
448449
/// Gets a list of all conflicting entries.
449450
/// </summary>
@@ -452,21 +453,19 @@ void GetConflictItems(ShortcutListItem target)
452453
var keys = target.Custom;
453454
if (keys == 0) return;
454455

455-
var conflicts = new List<ShortcutListItem> { target };
456+
List<ShortcutListItem> conflicts = null;
456457

457458
for (int i = 0; i < this.shortcutListItems.Length; i++)
458459
{
459460
var item = this.shortcutListItems[i];
460461

461-
if (item == target) continue;
462-
if (item.Custom == keys)
463-
{
464-
conflicts.Add(item);
465-
item.Conflicts = conflicts;
466-
}
462+
if (item.Custom != keys || item == target) continue;
463+
if (conflicts == null) conflicts = new List<ShortcutListItem> { target };
464+
conflicts.Add(item);
465+
item.Conflicts = conflicts;
467466
}
468467

469-
if (conflicts.Count > 1) target.Conflicts = conflicts;
468+
target.Conflicts = conflicts;
470469
}
471470

472471
/// <summary>
@@ -634,7 +633,7 @@ void DialogClosed(object sender, FormClosedEventArgs e)
634633

635634
#endregion
636635

637-
636+
638637
#region ListViewComparer
639638

640639
/// <summary>
@@ -720,6 +719,7 @@ public Keys Custom
720719
this.custom = value;
721720
this.KeysString = DataConverter.KeysToString(this.custom);
722721
this.SubItems[1].Text = this.KeysString;
722+
ResetConflicts(this);
723723
UpdateItemHighlightFont(this);
724724
}
725725
}
@@ -746,11 +746,13 @@ public bool IsModified
746746
/// </summary>
747747
public ShortcutListItem(ShortcutItem shortcutItem)
748748
{
749-
this.SubItems.Add(string.Empty);
750-
this.Name = this.Text = shortcutItem.Id;
751749
this.item = shortcutItem;
752750
this.conflicts = null;
753-
this.Custom = shortcutItem.Custom;
751+
this.custom = this.Item.Custom;
752+
this.KeysString = DataConverter.KeysToString(this.Custom);
753+
this.Name = this.Text = this.Id;
754+
this.SubItems.Add(this.KeysString);
755+
UpdateItemHighlightFont(this);
754756
}
755757

756758
/// <summary>

FlashDevelop/Managers/ShortcutManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Windows.Forms;
55
using FlashDevelop.Helpers;
66
using PluginCore;
7-
using PluginCore.Helpers;
87
using PluginCore.Managers;
98
using PluginCore.Utilities;
109
using ScintillaNet;
@@ -226,13 +225,14 @@ public static void LoadCustomShortcuts(String file, IEnumerable<IShortcutItem> i
226225
foreach (IShortcutItem item in items)
227226
{
228227
Keys newShortcut = item.Default;
229-
for (int i = 0; i < count; i++)
228+
for (Int32 i = 0; i < count; i++)
230229
{
231230
Argument arg = customShortcuts[i];
232231
if (arg.Key == item.Id)
233232
{
234233
newShortcut = (Keys) Enum.Parse(typeof(Keys), arg.Value);
235234
customShortcuts.RemoveAt(i);
235+
count--;
236236
break;
237237
}
238238
}

0 commit comments

Comments
 (0)