@@ -1070,22 +1070,28 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
10701070 let scriptArgs = List.tail args
10711071
10721072 // Filter out and process preferreduilang from script args
1073+ let isPreferredUiLangArg ( arg : string ) =
1074+ arg.StartsWith( " --preferreduilang:" , StringComparison.OrdinalIgnoreCase)
1075+ || arg.StartsWith( " /preferreduilang:" , StringComparison.OrdinalIgnoreCase)
1076+
10731077 let rec filterScriptArgs ( args : string list ) =
10741078 match args with
10751079 | [] -> []
1076- | ( arg: string) :: rest when
1077- arg.StartsWith( " --preferreduilang:" , StringComparison.OrdinalIgnoreCase)
1078- || arg.StartsWith( " /preferreduilang:" , StringComparison.OrdinalIgnoreCase)
1079- ->
1080+ | ( arg: string) :: rest when isPreferredUiLangArg arg ->
10801081 // Extract culture and set it
1081- let culture = arg.Substring( arg.IndexOf( ':' ) + 1 )
1082-
1083- try
1084- tcConfigB.preferredUiLang <- Some culture
1085- Thread.CurrentThread.CurrentUICulture <- CultureInfo( culture)
1086- with _ ->
1087- // Ignore invalid culture, just don't set it
1088- ()
1082+ let colonIndex = arg.IndexOf( ':' )
1083+
1084+ if colonIndex >= 0 && colonIndex < arg.Length - 1 then
1085+ let culture = arg.Substring( colonIndex + 1 )
1086+
1087+ try
1088+ tcConfigB.preferredUiLang <- Some culture
1089+ Thread.CurrentThread.CurrentUICulture <- CultureInfo( culture)
1090+ with
1091+ | :? CultureNotFoundException
1092+ | :? ArgumentException ->
1093+ // Ignore invalid culture, just don't set it
1094+ ()
10891095
10901096 filterScriptArgs rest
10911097 | arg :: rest -> arg :: filterScriptArgs rest
0 commit comments