-
-
Notifications
You must be signed in to change notification settings - Fork 448
Disabled space input in websearch and explorer & Improve API documents #3449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabled space input in websearch and explorer & Improve API documents #3449
Conversation
… for plugins that do not support multiple action keywords.
This comment has been minimized.
This comment has been minimized.
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
📝 WalkthroughWalkthroughThis pull request introduces new event handlers for paste operations and key down events in two plugins. In both Explorer and WebSearch plugins, the paste event is intercepted to validate the inserted text by rejecting content that contains whitespace or is of an unexpected data type. Additionally, a key down event handler has been added to block the Space key input in specific text boxes. Minor UI adjustments include the standardization of margin formatting. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TextBox
participant PasteHandler
User->>TextBox: Initiates paste operation
TextBox->>PasteHandler: Triggers DataObject.Pasting event
PasteHandler->>PasteHandler: Validate pasted data (text type and no whitespace)
alt Invalid content (contains whitespace or non-text)
PasteHandler->>TextBox: Cancel paste command
else Valid content
PasteHandler->>TextBox: Allow paste command
end
sequenceDiagram
participant User
participant TextBox
participant KeyDownHandler
User->>TextBox: Presses Space key
TextBox->>KeyDownHandler: Raises KeyDown/PreviewKeyDown event
KeyDownHandler->>KeyDownHandler: Detects Space key press
KeyDownHandler->>TextBox: Sets event.Handled to true (blocks input)
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs (1)
102-116
: Comprehensive paste validation for whitespace prevention.The implementation properly validates pasted content and prevents pasting text with whitespace characters, as well as non-text data. Consider adding a brief XML comment to explain the method's purpose.
+/// <summary> +/// Validates pasted content to prevent whitespace in action keywords as this plugin doesn't support multiple keywords. +/// </summary> private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs (1)
149-156
: Proper implementation of Space key blocking.This method correctly prevents users from entering Space characters, which supports the PR's goal of preventing whitespace in action keywords.
-//Block Space Input +// Prevent whitespace in action keywords as this plugin doesn't support multiple keywords private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml
(1 hunks)Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
(2 hunks)Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml
(7 hunks)Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
🔇 Additional comments (5)
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml (1)
83-83
: Good addition of paste validation!This new event handler ensures that whitespace cannot be introduced via pasting operations, supporting the PR's objective of preventing whitespace in action keywords for plugins that don't support multiple keywords.
Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml (2)
174-175
: Appropriate input validation!The addition of both paste validation and key press handling ensures that whitespace cannot be entered in the action keyword field, which aligns with the PR objective.
59-59
: Consistent margin format standardization.The margins have been updated from comma-separated to space-separated format, improving readability and maintaining consistency across the codebase.
Also applies to: 62-62, 65-65, 71-71, 78-78, 86-86, 108-108, 171-171, 180-180, 188-188, 201-201, 205-205, 210-210
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs (1)
97-101
: Proper Space key blocking.This addition prevents users from entering Space characters, which aligns with preventing whitespace in action keywords for plugins that don't support multiple keywords.
Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs (1)
157-171
: Well-implemented paste validation.The implementation correctly cancels paste operations when the content contains whitespace or is not valid text data, enforcing the constraint consistently.
# Conflicts: # Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
This comment has been minimized.
This comment has been minimized.
@coderabbitai Review It. By the way, is it okay to use LINQ? I’m wondering if other developers might find it annoying or not. |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@onesounds I've reviewed your PR and it looks good! The changes properly prevent whitespace input in action keyword fields both via keyboard input and paste operations, which accomplishes the stated goal. Regarding LINQ usage - it's absolutely fine to use LINQ in this codebase. It's already widely used throughout the project, and your specific usage (the The changes you've made are well-implemented and the LINQ usage enhances rather than detracts from code quality. No concerns there! 🏁 Script executed:
Length of output: 3752 @onesounds I've reviewed your PR and analyzed the codebase to answer your question about LINQ usage. Your changes look good! The implementation effectively prevents whitespace in action keyword fields through both keyboard blocking and paste validation. Regarding LINQ usage - it's absolutely fine and even encouraged in this codebase. The analysis shows:
Your implementation is perfectly aligned with the project's coding style. Using LINQ here makes the code more readable and concise, which is exactly what LINQ is designed for. Other developers will likely appreciate this approach as it follows established patterns in the codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A concise update to disable multi-whitespace input for action keywords in the WebSearch and Explorer plugins.
- Added keydown event handlers to block whitespace input via the keyboard.
- Added paste event handlers to cancel commands when pasted content contains whitespace.
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs | Added event handlers to block space input and pasted whitespace. |
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs | Added event handlers to block space input and pasted whitespace. |
Files not reviewed (2)
- Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml: Language not supported
- Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml: Language not supported
Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
Show resolved
Hide resolved
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to me.
What's the PR
Although multiple action keywords can now be registered using spaces, this feature does not apply to plugins that do not internally support multiple action keywords.
To prevent user confusion or unintended attempts, code has been added to block whitespace input (including space, tab, and pasted whitespace) in the action keyword registration TextBox for such plugins.
This is handled at the UI input level to avoid complex internal processing and in case multi-keyword support is implemented in the future.
Applied to the Websearch and Explorer plugins.
Follows on from #3261