Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Aug 23, 2024
1 parent ae47003 commit 5014fc6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions JL.Core/Dicts/DictUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions JL.Core/Lookup/LookupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private static List<LookupResult> SortLookupResults(IEnumerable<LookupResult> lo
? Array.IndexOf(lookupResult.Readings, lookupResult.MatchedText)
: -1;
if (index is -1)
if (index < 0)
{
return 3;
}
Expand Down Expand Up @@ -429,7 +429,7 @@ private static List<LookupResult> SortLookupResults(IEnumerable<LookupResult> lo
? Array.IndexOf(lookupResult.Readings, lookupResult.MatchedText)
: -1;
return index is not -1
return index >= 0
? index
: int.MaxValue;
})
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions JL.Core/Utilities/JapaneseUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -339,15 +339,15 @@ 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;
}
}

++startPosition;

if (endPosition is -1)
if (endPosition < 0)
{
endPosition = text.Length - 1;
}
Expand Down Expand Up @@ -431,7 +431,7 @@ private static int FirstPunctuationIndex(ReadOnlySpan<char> text)
public static string RemovePunctuation(string text)
{
int index = FirstPunctuationIndex(text);
if (index is -1)
if (index < 0)
{
return text;
}
Expand Down
2 changes: 1 addition & 1 deletion JL.Core/Utilities/TextUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions JL.Windows/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
{
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 5014fc6

Please sign in to comment.