mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[cmdpal] Fix calculator error when pressing Space (#39679)
Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
@@ -35,7 +35,7 @@ public static class CalculateHelper
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(input))
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(paramName: nameof(input));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RegValidExpressChar.IsMatch(input))
|
if (!RegValidExpressChar.IsMatch(input))
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public static partial class QueryHelper
|
|||||||
NumberTranslator translator = NumberTranslator.Create(inputCulture, new CultureInfo("en-US"));
|
NumberTranslator translator = NumberTranslator.Create(inputCulture, new CultureInfo("en-US"));
|
||||||
var input = translator.Translate(query.Normalize(NormalizationForm.FormKC));
|
var input = translator.Translate(query.Normalize(NormalizationForm.FormKC));
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
|
{
|
||||||
|
return ErrorHandler.OnError(isFallbackSearch, query, Properties.Resources.calculator_expression_empty);
|
||||||
|
}
|
||||||
|
|
||||||
if (!CalculateHelper.InputValid(input))
|
if (!CalculateHelper.InputValid(input))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -132,6 +132,15 @@ namespace Microsoft.CmdPal.Ext.Calc.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Please enter an expression.
|
||||||
|
/// </summary>
|
||||||
|
public static string calculator_expression_empty {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("calculator_expression_empty", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Expression wrong or incomplete.
|
/// Looks up a localized string similar to Expression wrong or incomplete.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -199,4 +199,7 @@
|
|||||||
<data name="calculator_copy_binary" xml:space="preserve">
|
<data name="calculator_copy_binary" xml:space="preserve">
|
||||||
<value>Copy binary</value>
|
<value>Copy binary</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="calculator_expression_empty" xml:space="preserve">
|
||||||
|
<value>Please enter an expression</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user