Skip to content

Commit e8353f7

Browse files
authored
Merge pull request #4339 from Flow-Launcher/copilot/fix-folder-search-action
Fix ArgumentException when editing a disabled Explorer action keyword
2 parents 8d042d2 + 531b452 commit e8353f7

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ internal enum ActionKeyword
230230
internal Dictionary<ActionKeyword, string> GetActiveActionKeywords(string actionKeywordStr)
231231
{
232232
var result = new Dictionary<ActionKeyword, string>();
233-
if (string.IsNullOrEmpty(actionKeywordStr)) return null;
233+
if (string.IsNullOrEmpty(actionKeywordStr)) return result;
234234
foreach (var action in Enum.GetValues<ActionKeyword>())
235235
{
236236
var keywordStr = GetActionKeyword(action);

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ private void EditActionKeyword(object obj)
321321
Context.API.AddActionKeyword(Context.CurrentPluginMetadata.ID, actionKeywordWindow.ActionKeyword);
322322
break;
323323
case (false, false):
324-
throw new ArgumentException(
325-
$"Both false in {nameof(actionKeyword)}.{nameof(actionKeyword.Enabled)} and {nameof(actionKeywordWindow)}.{nameof(actionKeywordWindow.KeywordEnabled)} should suggest that the ShowDialog() result is false");
324+
// Keyword was disabled and remains disabled, but the keyword text was changed.
325+
// No action keyword registration changes needed; the model will be updated below.
326+
break;
326327
}
327328

328329
(actionKeyword.Keyword, actionKeyword.Enabled) = (actionKeywordWindow.ActionKeyword, actionKeywordWindow.KeywordEnabled);

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
VerticalAlignment="Center"
8383
DataObject.Pasting="TextBox_Pasting"
8484
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
85-
Text="{Binding ActionKeyword}" />
85+
Text="{Binding ActionKeyword, UpdateSourceTrigger=PropertyChanged}" />
8686
</StackPanel>
8787
<StackPanel Margin="0 10 0 15" Orientation="Horizontal">
8888
<TextBlock

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public string ActionKeyword
1616
get => actionKeyword;
1717
set
1818
{
19-
// Set Enable to be true if user change ActionKeyword
20-
KeywordEnabled = true;
21-
_ = SetProperty(ref actionKeyword, value);
19+
// Set Enable to be true only when the ActionKeyword value actually changes
20+
if (SetProperty(ref actionKeyword, value))
21+
KeywordEnabled = true;
2222
}
2323
}
2424

@@ -34,8 +34,9 @@ public bool KeywordEnabled
3434
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword)
3535
{
3636
CurrentActionKeyword = selectedActionKeyword;
37-
ActionKeyword = selectedActionKeyword.Keyword;
38-
KeywordEnabled = selectedActionKeyword.Enabled;
37+
// Initialize backing fields directly to avoid triggering the auto-enable side-effect
38+
actionKeyword = selectedActionKeyword.Keyword;
39+
_keywordEnabled = selectedActionKeyword.Enabled;
3940

4041
InitializeComponent();
4142

0 commit comments

Comments
 (0)