code_style: use ?: operator instead of if...else

This commit is contained in:
leo 2024-05-07 14:28:34 +08:00
parent 4af8cc18d2
commit 15456f0dee

View file

@ -134,15 +134,7 @@ namespace SourceGit.ViewModels
var activeIdx = Pages.IndexOf(_activePage); var activeIdx = Pages.IndexOf(_activePage);
if (removeIdx == activeIdx) if (removeIdx == activeIdx)
{ {
if (removeIdx == Pages.Count - 1) ActivePage = Pages[removeIdx == Pages.Count - 1 ? removeIdx - 1 : removeIdx + 1];
{
ActivePage = Pages[removeIdx - 1];
}
else
{
ActivePage = Pages[removeIdx + 1];
}
CloseRepositoryInTab(page); CloseRepositoryInTab(page);
Pages.RemoveAt(removeIdx); Pages.RemoveAt(removeIdx);
OnPropertyChanged(nameof(Pages)); OnPropertyChanged(nameof(Pages));