mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Refactor] Invert if to reduce nesting.
This commit is contained in:
@@ -485,17 +485,14 @@ public partial class SpectreTextBlock : TextBlock
|
||||
{
|
||||
i++;
|
||||
|
||||
if(i < text.Length && text[i] == ']')
|
||||
{
|
||||
// Found [/], close the most recent tag
|
||||
if(tagStack.Count > 0)
|
||||
{
|
||||
(int openStart, int openTagEnd, string tag) = tagStack.Pop();
|
||||
int closeTagEnd = i + 1; // After the ']' of [/]
|
||||
result.Add(new MarkupTag(openStart, closeTagEnd, tag, openTagEnd, tagStart));
|
||||
}
|
||||
if(i >= text.Length || text[i] != ']') continue;
|
||||
|
||||
i++;
|
||||
// Found [/], close the most recent tag
|
||||
if(tagStack.Count > 0)
|
||||
{
|
||||
(int openStart, int openTagEnd, string tag) = tagStack.Pop();
|
||||
int closeTagEnd = i + 1; // After the ']' of [/]
|
||||
result.Add(new MarkupTag(openStart, closeTagEnd, tag, openTagEnd, tagStart));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -513,12 +510,10 @@ public partial class SpectreTextBlock : TextBlock
|
||||
int openTagEnd = i + 1; // After the ']'
|
||||
tagStack.Push((tagStart, openTagEnd, tagName));
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
i++;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -40,14 +40,11 @@ public partial class FileView : UserControl
|
||||
|
||||
private void ListBox_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if(e.Key == Key.Enter)
|
||||
{
|
||||
if(DataContext is FileViewViewModel vm && vm.OpenSelectedFileCommand.CanExecute(null))
|
||||
{
|
||||
vm.OpenSelectedFileCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
if(e.Key != Key.Enter) return;
|
||||
if(DataContext is not FileViewViewModel vm || !vm.OpenSelectedFileCommand.CanExecute(null)) return;
|
||||
|
||||
vm.OpenSelectedFileCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user