diff --git a/JL.Core/Dicts/DictUtils.cs b/JL.Core/Dicts/DictUtils.cs index 16c01f1c..166f6bcc 100644 --- a/JL.Core/Dicts/DictUtils.cs +++ b/JL.Core/Dicts/DictUtils.cs @@ -1323,7 +1323,7 @@ internal static async Task InitializeKanjiCompositionDict() int endIndex = lParts[2].IndexOf('[', StringComparison.Ordinal); KanjiCompositionDict.Add(lParts[1].GetPooledString(), - endIndex is -1 ? lParts[2] : lParts[2][..endIndex]); + endIndex < 0 ? lParts[2] : lParts[2][..endIndex]); } else if (lParts.Length > 3) @@ -1333,7 +1333,7 @@ internal static async Task InitializeKanjiCompositionDict() if (lParts[j].Contains('J', StringComparison.Ordinal)) { int endIndex = lParts[j].IndexOf('[', StringComparison.Ordinal); - if (endIndex is not -1) + if (endIndex >= 0) { KanjiCompositionDict.Add(lParts[1].GetPooledString(), lParts[j][..endIndex]); break; diff --git a/JL.Core/Lookup/LookupUtils.cs b/JL.Core/Lookup/LookupUtils.cs index 510a2513..9f7f310e 100644 --- a/JL.Core/Lookup/LookupUtils.cs +++ b/JL.Core/Lookup/LookupUtils.cs @@ -379,7 +379,7 @@ private static List SortLookupResults(IEnumerable lo ? Array.IndexOf(lookupResult.Readings, lookupResult.MatchedText) : -1; - if (index is -1) + if (index < 0) { return 3; } @@ -429,7 +429,7 @@ private static List SortLookupResults(IEnumerable lo ? Array.IndexOf(lookupResult.Readings, lookupResult.MatchedText) : -1; - return index is not -1 + return index >= 0 ? index : int.MaxValue; }) @@ -473,7 +473,7 @@ private static (bool tryLongVowelConversion, int succAttempt) GetWordResultsHelp if (r.MatchedText == deconjugationResult.OriginalText) { int index = r.Results.FindIndex(rs => rs.SequenceEqual(resultsList)); - if (index is not -1) + if (index >= 0) { //if (!r.Processes?[index].Any(p => p.SequenceEqual(deconjugationResult.Process)) ?? false) r.Processes?[index].Add(deconjugationResult.Process); diff --git a/JL.Core/Utilities/JapaneseUtils.cs b/JL.Core/Utilities/JapaneseUtils.cs index e4bc1487..a9cb5704 100644 --- a/JL.Core/Utilities/JapaneseUtils.cs +++ b/JL.Core/Utilities/JapaneseUtils.cs @@ -201,7 +201,7 @@ public static string KatakanaToHiragana(string text) normalizedText = normalizedText.ToUpperInvariant(); int firstKatakanaIndex = FirstKatakanaIndex(normalizedText); - if (firstKatakanaIndex is -1) + if (firstKatakanaIndex < 0) { return normalizedText; } @@ -339,7 +339,7 @@ internal static string FindSentence(string text, int position) tempIndex = text.IndexOf(terminatingCharacter, position); - if (tempIndex is not -1 && (endPosition is -1 || tempIndex < endPosition)) + if (tempIndex >= 0 && (endPosition < 0 || tempIndex < endPosition)) { endPosition = tempIndex; } @@ -347,7 +347,7 @@ internal static string FindSentence(string text, int position) ++startPosition; - if (endPosition is -1) + if (endPosition < 0) { endPosition = text.Length - 1; } @@ -431,7 +431,7 @@ private static int FirstPunctuationIndex(ReadOnlySpan text) public static string RemovePunctuation(string text) { int index = FirstPunctuationIndex(text); - if (index is -1) + if (index < 0) { return text; } diff --git a/JL.Core/Utilities/TextUtils.cs b/JL.Core/Utilities/TextUtils.cs index 0ee0c70a..1d92daea 100644 --- a/JL.Core/Utilities/TextUtils.cs +++ b/JL.Core/Utilities/TextUtils.cs @@ -71,7 +71,7 @@ private static string RemoveInvalidUnicodeSequences(string text, int index) public static string SanitizeText(string text) { int firstInvalidUnicodeCharIndex = FirstInvalidUnicodeSequenceIndex(text); - if (firstInvalidUnicodeCharIndex is not -1) + if (firstInvalidUnicodeCharIndex >= 0) { text = RemoveInvalidUnicodeSequences(text, firstInvalidUnicodeCharIndex); } diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index f7cca7e6..292e851c 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -814,7 +814,7 @@ public static void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.MainWindowFontComboBox.SelectedIndex = Array.FindIndex(s_japaneseFonts, static f => f.Content.ToString() == MainWindow.Instance.MainTextBox.FontFamily.Source); - if (preferenceWindow.MainWindowFontComboBox.SelectedIndex is -1) + if (preferenceWindow.MainWindowFontComboBox.SelectedIndex < 0) { preferenceWindow.MainWindowFontComboBox.SelectedIndex = 0; } @@ -823,7 +823,7 @@ public static void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.PopupFontComboBox.SelectedIndex = Array.FindIndex(s_popupJapaneseFonts, static f => f.Content.ToString() == PopupFont.Source); - if (preferenceWindow.PopupFontComboBox.SelectedIndex is -1) + if (preferenceWindow.PopupFontComboBox.SelectedIndex < 0) { preferenceWindow.PopupFontComboBox.SelectedIndex = 0; } @@ -855,7 +855,7 @@ public static void LoadPreferenceWindow(PreferencesWindow preferenceWindow) preferenceWindow.PopupXOffsetNumericUpDown.Value = PopupXOffset; preferenceWindow.PopupYOffsetNumericUpDown.Value = PopupYOffset; - if (preferenceWindow.LookupModeComboBox.SelectedIndex is -1) + if (preferenceWindow.LookupModeComboBox.SelectedIndex < 0) { preferenceWindow.LookupModeComboBox.SelectedIndex = 0; } diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index e6b12a62..e4882766 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -958,7 +958,7 @@ public void ShowAddNameWindow() { string? text = MainTextBox.SelectionLength > 0 ? MainTextBox.SelectedText - : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) is not -1 + : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) >= 0 || (FirstPopupWindow.LastSelectedText is not null && MainTextBox.Text.StartsWith(FirstPopupWindow.LastSelectedText, StringComparison.Ordinal)) ? FirstPopupWindow.LastSelectedText @@ -991,7 +991,7 @@ public void ShowAddWordWindow() { string? text = MainTextBox.SelectionLength > 0 ? MainTextBox.SelectedText - : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) is not -1 + : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) >= 0 || (FirstPopupWindow.LastSelectedText is not null && MainTextBox.Text.StartsWith(FirstPopupWindow.LastSelectedText, StringComparison.Ordinal)) ? FirstPopupWindow.LastSelectedText @@ -1014,7 +1014,7 @@ public void SearchWithBrowser() { string? text = MainTextBox.SelectionLength > 0 ? MainTextBox.SelectedText - : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) is not -1 + : MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), false) >= 0 || (FirstPopupWindow.LastSelectedText is not null && MainTextBox.Text.StartsWith(FirstPopupWindow.LastSelectedText, StringComparison.Ordinal)) ? FirstPopupWindow.LastSelectedText diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index 9d59c0f4..4220fcff 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -307,7 +307,7 @@ public Task LookupOnMouseMoveOrClick(TextBox textBox) { int charPosition = textBox.GetCharacterIndexFromPoint(Mouse.GetPosition(textBox), false); - if (charPosition is not -1) + if (charPosition >= 0) { if (charPosition > 0 && char.IsHighSurrogate(textBox.Text[charPosition - 1])) { @@ -1281,7 +1281,7 @@ private void SelectNextLookupResult() private void SelectPreviousLookupResult() { - int nextItemIndex = PopupListView.SelectedIndex - 1 > -1 + int nextItemIndex = PopupListView.SelectedIndex - 1 >= 0 ? PopupListView.SelectedIndex - 1 : PopupListView.Items.Count - 1;