From 649b142b46b3c8f49b3c92f2a2b71a993e7e1f0b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 10 Jan 2026 06:30:57 +0000
Subject: [PATCH] Add UseThousandsSeparator setting to Calculator plugin
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
---
Flow.Launcher.Test/Plugins/CalculatorTest.cs | 35 ++++++++++++++++++-
.../Languages/en.xaml | 1 +
.../Flow.Launcher.Plugin.Calculator/Main.cs | 2 +-
.../Settings.cs | 2 ++
.../Views/CalculatorSettings.xaml | 11 ++++++
5 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher.Test/Plugins/CalculatorTest.cs b/Flow.Launcher.Test/Plugins/CalculatorTest.cs
index b075813db..8178cb712 100644
--- a/Flow.Launcher.Test/Plugins/CalculatorTest.cs
+++ b/Flow.Launcher.Test/Plugins/CalculatorTest.cs
@@ -16,7 +16,8 @@ namespace Flow.Launcher.Test.Plugins
{
DecimalSeparator = DecimalSeparator.UseSystemLocale,
MaxDecimalPlaces = 10,
- ShowErrorMessage = false // Make sure we return the empty results when error occurs
+ ShowErrorMessage = false, // Make sure we return the empty results when error occurs
+ UseThousandsSeparator = true // Default value
};
private readonly Engine _engine = new(new Configuration
{
@@ -41,6 +42,38 @@ namespace Flow.Launcher.Test.Plugins
engineField.SetValue(null, _engine);
}
+ [Test]
+ public void ThousandsSeparatorTest_Enabled()
+ {
+ _settings.UseThousandsSeparator = true;
+ _settings.DecimalSeparator = DecimalSeparator.Dot;
+
+ var result = GetCalculationResult("1000+234");
+ // When thousands separator is enabled, the result should contain a separator (comma in this case)
+ ClassicAssert.IsTrue(result.Contains(",") || result == "1234",
+ "Expected result to contain thousands separator or be without one if system doesn't use it");
+ }
+
+ [Test]
+ public void ThousandsSeparatorTest_Disabled()
+ {
+ _settings.UseThousandsSeparator = false;
+ _settings.DecimalSeparator = DecimalSeparator.Dot;
+
+ var result = GetCalculationResult("1000+234");
+ ClassicAssert.AreEqual("1234", result);
+ }
+
+ [Test]
+ public void ThousandsSeparatorTest_LargeNumber()
+ {
+ _settings.UseThousandsSeparator = false;
+ _settings.DecimalSeparator = DecimalSeparator.Dot;
+
+ var result = GetCalculationResult("1000000+234567");
+ ClassicAssert.AreEqual("1234567", result);
+ }
+
// Basic operations
[TestCase(@"1+1", "2")]
[TestCase(@"2-1", "1")]
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Calculator/Languages/en.xaml
index b12972b1b..4b9fd92b1 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Languages/en.xaml
@@ -14,6 +14,7 @@
Comma (,)
Dot (.)
Max. decimal places
+ Use thousands separator
Copy failed, please try later
Show error message when calculation fails
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
index a20a1ad5d..1b9a38e18 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
@@ -363,7 +363,7 @@ namespace Flow.Launcher.Plugin.Calculator
string integerPart = parts[0];
string fractionalPart = parts.Length > 1 ? parts[1] : string.Empty;
- if (integerPart.Length > 3)
+ if (_settings.UseThousandsSeparator && integerPart.Length > 3)
{
integerPart = ThousandGroupRegex.Replace(integerPart, groupSeparator);
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs
index 1544dc41f..69cd17ed2 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs
@@ -7,4 +7,6 @@ public class Settings
public int MaxDecimalPlaces { get; set; } = 10;
public bool ShowErrorMessage { get; set; } = false;
+
+ public bool UseThousandsSeparator { get; set; } = true;
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml b/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
index 9e7549b2d..82f8eec60 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Views/CalculatorSettings.xaml
@@ -16,6 +16,7 @@
+
@@ -66,6 +67,16 @@
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
+ Content="{DynamicResource flowlauncher_plugin_calculator_use_thousands_separator}"
+ IsChecked="{Binding Settings.UseThousandsSeparator, Mode=TwoWay}" />
+
+