Merge pull request #4339 from Flow-Launcher/copilot/fix-folder-search-action
Some checks failed
Build / build (push) Has been cancelled

Fix ArgumentException when editing a disabled Explorer action keyword
This commit is contained in:
Jack Ye 2026-03-10 23:29:51 +08:00 committed by GitHub
commit e8353f7648
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 9 deletions

View file

@ -230,7 +230,7 @@ namespace Flow.Launcher.Plugin.Explorer
internal Dictionary<ActionKeyword, string> GetActiveActionKeywords(string actionKeywordStr)
{
var result = new Dictionary<ActionKeyword, string>();
if (string.IsNullOrEmpty(actionKeywordStr)) return null;
if (string.IsNullOrEmpty(actionKeywordStr)) return result;
foreach (var action in Enum.GetValues<ActionKeyword>())
{
var keywordStr = GetActionKeyword(action);

View file

@ -321,8 +321,9 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
Context.API.AddActionKeyword(Context.CurrentPluginMetadata.ID, actionKeywordWindow.ActionKeyword);
break;
case (false, false):
throw new ArgumentException(
$"Both false in {nameof(actionKeyword)}.{nameof(actionKeyword.Enabled)} and {nameof(actionKeywordWindow)}.{nameof(actionKeywordWindow.KeywordEnabled)} should suggest that the ShowDialog() result is false");
// Keyword was disabled and remains disabled, but the keyword text was changed.
// No action keyword registration changes needed; the model will be updated below.
break;
}
(actionKeyword.Keyword, actionKeyword.Enabled) = (actionKeywordWindow.ActionKeyword, actionKeywordWindow.KeywordEnabled);

View file

@ -82,7 +82,7 @@
VerticalAlignment="Center"
DataObject.Pasting="TextBox_Pasting"
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
Text="{Binding ActionKeyword}" />
Text="{Binding ActionKeyword, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Margin="0 10 0 15" Orientation="Horizontal">
<TextBlock

View file

@ -16,9 +16,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
get => actionKeyword;
set
{
// Set Enable to be true if user change ActionKeyword
KeywordEnabled = true;
_ = SetProperty(ref actionKeyword, value);
// Set Enable to be true only when the ActionKeyword value actually changes
if (SetProperty(ref actionKeyword, value))
KeywordEnabled = true;
}
}
@ -34,8 +34,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword)
{
CurrentActionKeyword = selectedActionKeyword;
ActionKeyword = selectedActionKeyword.Keyword;
KeywordEnabled = selectedActionKeyword.Enabled;
// Initialize backing fields directly to avoid triggering the auto-enable side-effect
actionKeyword = selectedActionKeyword.Keyword;
_keywordEnabled = selectedActionKeyword.Enabled;
InitializeComponent();