mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix exception when setting Folder Search action keyword in Explorer plugin
- Fix (false, false) case in EditActionKeyword to break gracefully instead of throwing ArgumentException. This handles the valid scenario where the user changes a disabled keyword's text but keeps it disabled. - Fix GetActiveActionKeywords to return an empty dictionary instead of null when actionKeywordStr is null/empty, preventing NullReferenceException. - Fix ActionKeyword setter to only auto-enable when the value actually changes, preventing unintended side-effects during construction. - Initialize ActionKeywordSetting backing fields directly in constructor to avoid the auto-enable triggering during initialization. - Change TextBox binding to UpdateSourceTrigger=PropertyChanged so the checkbox auto-enables as the user types (before they click the checkbox), fixing the checkbox toggle issue caused by LostFocus timing. Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
This commit is contained in:
parent
319db64393
commit
531b45210a
4 changed files with 11 additions and 9 deletions
|
|
@ -230,7 +230,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
internal Dictionary<ActionKeyword, string> GetActiveActionKeywords(string actionKeywordStr)
|
internal Dictionary<ActionKeyword, string> GetActiveActionKeywords(string actionKeywordStr)
|
||||||
{
|
{
|
||||||
var result = new Dictionary<ActionKeyword, string>();
|
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>())
|
foreach (var action in Enum.GetValues<ActionKeyword>())
|
||||||
{
|
{
|
||||||
var keywordStr = GetActionKeyword(action);
|
var keywordStr = GetActionKeyword(action);
|
||||||
|
|
|
||||||
|
|
@ -321,8 +321,9 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
||||||
Context.API.AddActionKeyword(Context.CurrentPluginMetadata.ID, actionKeywordWindow.ActionKeyword);
|
Context.API.AddActionKeyword(Context.CurrentPluginMetadata.ID, actionKeywordWindow.ActionKeyword);
|
||||||
break;
|
break;
|
||||||
case (false, false):
|
case (false, false):
|
||||||
throw new ArgumentException(
|
// Keyword was disabled and remains disabled, but the keyword text was changed.
|
||||||
$"Both false in {nameof(actionKeyword)}.{nameof(actionKeyword.Enabled)} and {nameof(actionKeywordWindow)}.{nameof(actionKeywordWindow.KeywordEnabled)} should suggest that the ShowDialog() result is false");
|
// No action keyword registration changes needed; the model will be updated below.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(actionKeyword.Keyword, actionKeyword.Enabled) = (actionKeywordWindow.ActionKeyword, actionKeywordWindow.KeywordEnabled);
|
(actionKeyword.Keyword, actionKeyword.Enabled) = (actionKeywordWindow.ActionKeyword, actionKeywordWindow.KeywordEnabled);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DataObject.Pasting="TextBox_Pasting"
|
DataObject.Pasting="TextBox_Pasting"
|
||||||
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
|
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
|
||||||
Text="{Binding ActionKeyword}" />
|
Text="{Binding ActionKeyword, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Margin="0 10 0 15" Orientation="Horizontal">
|
<StackPanel Margin="0 10 0 15" Orientation="Horizontal">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
get => actionKeyword;
|
get => actionKeyword;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// Set Enable to be true if user change ActionKeyword
|
// Set Enable to be true only when the ActionKeyword value actually changes
|
||||||
KeywordEnabled = true;
|
if (SetProperty(ref actionKeyword, value))
|
||||||
_ = SetProperty(ref actionKeyword, value);
|
KeywordEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,8 +34,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword)
|
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword)
|
||||||
{
|
{
|
||||||
CurrentActionKeyword = selectedActionKeyword;
|
CurrentActionKeyword = selectedActionKeyword;
|
||||||
ActionKeyword = selectedActionKeyword.Keyword;
|
// Initialize backing fields directly to avoid triggering the auto-enable side-effect
|
||||||
KeywordEnabled = selectedActionKeyword.Enabled;
|
actionKeyword = selectedActionKeyword.Keyword;
|
||||||
|
_keywordEnabled = selectedActionKeyword.Enabled;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue