File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Plugins/Flow.Launcher.Plugin.Calculator Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ private string NormalizeNumber(string numberStr)
139139 {
140140 var culture = CultureInfo . CurrentCulture ;
141141 var groupSep = culture . NumberFormat . NumberGroupSeparator ;
142+ var decimalSep = culture . NumberFormat . NumberDecimalSeparator ;
142143
143144 // If the string contains the group separator, check if it's used correctly.
144145 if ( ! string . IsNullOrEmpty ( groupSep ) && numberStr . Contains ( groupSep ) )
@@ -164,14 +165,11 @@ private string NormalizeNumber(string numberStr)
164165 }
165166 }
166167
167- // At this point, any group separators are in valid positions (or there are none).
168- // We can safely parse with the user's culture.
169- if ( decimal . TryParse ( numberStr , NumberStyles . Any , culture , out var number ) )
170- {
171- return number . ToString ( CultureInfo . InvariantCulture ) ;
172- }
168+ // If validation passes, we can assume the separators are used correctly for numbers.
169+ string processedStr = numberStr . Replace ( groupSep , "" ) ;
170+ processedStr = processedStr . Replace ( decimalSep , "." ) ;
173171
174- return numberStr ;
172+ return processedStr ;
175173 }
176174
177175 private string FormatResult ( decimal roundedResult )
You can’t perform that action at this time.
0 commit comments