Compare commits

...

1 Commits

Author SHA1 Message Date
Mike Griese
034cf9ef69 CmdPal: fix a crash on setting the same alias 2025-05-16 10:17:44 -05:00
2 changed files with 24 additions and 3 deletions

View File

@@ -86,18 +86,24 @@ public partial class AliasManager : ObservableObject
return;
}
// If we already have _this exact alias_, do nothing
// Look for the old alias, and remove it
List<CommandAlias> toRemove = [];
if (newAlias != null &&
_aliases.TryGetValue(newAlias.SearchPrefix, out var existingAlias))
{
if (existingAlias.CommandId == commandId)
{
// If we already have _this exact alias_, do nothing
return;
}
else
{
// We have _something else_ bound to this alias. Remove it.
toRemove.Add(existingAlias);
}
}
// Look for the old alias, and remove it
List<CommandAlias> toRemove = [];
foreach (var kv in _aliases)
{
if (kv.Value.CommandId == commandId)

View File

@@ -137,11 +137,20 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
item.PropertyChanged += Item_PropertyChanged;
_settings.SettingsChanged += SettingsChanged;
// UpdateAlias();
// UpdateHotkey();
// UpdateTags();
}
private void SettingsChanged(SettingsModel sender, object? args)
{
FetchAliasFromAliasManager();
UpdateHotkey();
UpdateTags();
}
private void Item_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!string.IsNullOrEmpty(e.PropertyName))
@@ -188,6 +197,12 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
// Decouple from the alias manager alias object
Alias = new CommandAlias(commandAlias.Alias, commandAlias.CommandId, commandAlias.IsDirect);
}
else
{
Alias = null;
}
UpdateTags();
}
}