Skip to content

Add rad2deg and deg2rad to default calculator plugin. #3754

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

Closed
wants to merge 8 commits into from

Conversation

Koisu-unavailable
Copy link

This PR adds two functions to the default calculator plugin: rad2deg which converts from radians to degrees, and deg2rad which converts from degrees to radians. I believe calculators that can do the trignometric functions are expected to be able to convert between degrees and radians.

Examples:

image

@Koisu-unavailable Koisu-unavailable marked this pull request as ready for review June 19, 2025 21:47
@coderabbitai coderabbitai bot added the enhancement New feature or request label Jun 19, 2025
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

📝 Walkthrough

Walkthrough

Support for two new mathematical functions, rad2deg and deg2rad, has been added to the calculator plugin. The expression engine now recognizes these functions, allowing users to convert between radians and degrees in their calculations. The regex pattern for allowed expressions and the plugin initialization have been updated accordingly. Additionally, the Explorer plugin introduces a new "Rename" action keyword (re:) with related settings, search handling, and UI localization.

Changes

File(s) Change Summary
Plugins/Flow.Launcher.Plugin.Calculator/Main.cs Added rad2deg and deg2rad functions to the expression engine and updated regex validation. Renamed variable matchs to matches in IsBracketComplete method.
Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml Added new localized string resource key plugin_explorer_actionkeywordview_rename with value "Rename:".
Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs Added handling for new RenameActionKeyword in SearchAsync and ActionKeywordMatch methods to provide a "Done" result.
Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs Added RenameActionKeyword property and enabled flag with defaults; extended internal ActionKeyword enum and related methods to support rename action keyword. Reformatted usings and properties for clarity.
Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs Added new ActionKeywordModel entry for RenameActionKeyword in InitializeActionKeywordModels method.

Suggested labels

enhancement

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
Plugins/Flow.Launcher.Plugin.Calculator/Main.cs (1)

49-51: Mathematical formulas are correct, but consider improving code consistency.

The conversion formulas are mathematically accurate:

  • rad2deg: rad * (180.0 / Math.PI) correctly converts radians to degrees
  • deg2rad: x * (Math.PI / 180.0) correctly converts degrees to radians

However, there's an inconsistency in the function definition approach - rad2deg is defined as a separate variable while deg2rad is defined inline.

Consider standardizing the function definitions for better consistency:

-Func<double, double> rad2deg = (rad) => rad * (180.0 / Math.PI);
-MagesEngine.SetFunction("rad2deg", rad2deg);
-MagesEngine.SetFunction("deg2rad", (double x) => x * (Math.PI / 180.0));
+MagesEngine.SetFunction("rad2deg", (double rad) => rad * (180.0 / Math.PI));
+MagesEngine.SetFunction("deg2rad", (double deg) => deg * (Math.PI / 180.0));

This approach:

  • Makes both functions consistent in style
  • Improves parameter naming (deg instead of x for degrees)
  • Reduces code verbosity
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40e5c04 and 4e03b76.

📒 Files selected for processing (1)
  • Plugins/Flow.Launcher.Plugin.Calculator/Main.cs (2 hunks)
🔇 Additional comments (1)
Plugins/Flow.Launcher.Plugin.Calculator/Main.cs (1)

19-19: LGTM! Regex pattern correctly updated for new functions.

The addition of rad2deg|deg2rad| to the regex pattern is necessary and correctly placed to allow expressions containing these function names to pass validation.

@VictoriousRaptor VictoriousRaptor added this to the 2.0.0 milestone Jun 20, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 762e1c7 and 8d8388b.

📒 Files selected for processing (4)
  • Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs (10 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
🧰 Additional context used
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

[warning] 282-282:
actionkeywordview is not a recognized word. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Report (PR)
🔇 Additional comments (5)
Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs (1)

282-284: Major inconsistency: Changes don't match PR description

The PR objectives describe adding rad2deg and deg2rad functions to the calculator plugin, but these changes are for the Explorer plugin's rename feature. This appears to be a mismatch between the PR description and the actual implementation.

Technical review: Implementation follows existing pattern

The addition of the rename action keyword model follows the established pattern and integrates properly with the existing settings UI structure.

Likely an incorrect or invalid review comment.

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs (1)

164-164: Rename action keyword matching implemented correctly

The addition to the ActionKeywordMatch method follows the established pattern and correctly checks both the enabled flag and keyword match.

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs (3)

64-65: Rename action keyword properties added correctly

The new RenameActionKeyword and RenameActionKeywordEnabled properties follow the established naming conventions and have reasonable default values.


187-188: Enum extended properly for rename functionality

The RenameActionKeyword addition to the internal enum maintains consistency with the existing action keyword structure.


191-259: Switch statement updates are comprehensive and consistent

All four switch statement methods (GetActionKeyword, SetActionKeyword, GetActionKeywordEnabled, SetActionKeywordEnabled) have been updated to handle the new RenameActionKeyword case with proper error handling for out-of-range values.

Comment on lines 50 to 59
if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword))
{
return new List<Result>()
{
new Result(){
Title = "Done",
AutoCompleteText = "test"
}
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace placeholder implementation with actual rename functionality

The rename action keyword handling returns hardcoded test values ("Done" title, "test" autocomplete text) which appears to be placeholder code. This should be replaced with proper rename functionality before merging.

-            if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword))
-            {
-                return new List<Result>()
-                {
-                    new Result(){
-                        Title = "Done",
-                        AutoCompleteText = "test"
-                    }
-                };
-            }
+            if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword))
+            {
+                // TODO: Implement actual rename functionality
+                // This should handle file/folder renaming logic
+                return new List<Result>();
+            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword))
{
return new List<Result>()
{
new Result(){
Title = "Done",
AutoCompleteText = "test"
}
};
}
if (ActionKeywordMatch(query, Settings.ActionKeyword.RenameActionKeyword))
{
// TODO: Implement actual rename functionality
// This should handle file/folder renaming logic
return new List<Result>();
}
🤖 Prompt for AI Agents
In Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs between lines
50 and 59, replace the placeholder return of a hardcoded Result with actual
rename functionality. Implement the logic to handle the rename action keyword
properly by generating appropriate Result objects that perform or initiate the
rename operation instead of returning static test values.

@Koisu-unavailable
Copy link
Author

Koisu-unavailable commented Jun 20, 2025

Sorry, I forgot how pull requests worked and accidentally committed other changes to the same branch, so I had to revert them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants