From aad91ea8346c9798b902085d154e776ddabd1398 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Fri, 21 Jun 2024 17:22:28 +0800 Subject: [PATCH] fix: NRE in WorkingCopy (#199) --- src/ViewModels/WorkingCopy.cs | 36 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index b0f91dea..8b9ef9cf 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -190,29 +190,17 @@ namespace SourceGit.ViewModels { _repo = null; - if (_selectedUnstaged != null) - { - _selectedUnstaged.Clear(); - OnPropertyChanged(nameof(SelectedUnstaged)); - } + _selectedUnstaged.Clear(); + OnPropertyChanged(nameof(SelectedUnstaged)); - if (_selectedStaged != null) - { - _selectedStaged.Clear(); - OnPropertyChanged(nameof(SelectedStaged)); - } + _selectedStaged.Clear(); + OnPropertyChanged(nameof(SelectedStaged)); - if (_unstaged != null) - { - _unstaged.Clear(); - OnPropertyChanged(nameof(Unstaged)); - } + _unstaged.Clear(); + OnPropertyChanged(nameof(Unstaged)); - if (_staged != null) - { - _staged.Clear(); - OnPropertyChanged(nameof(Staged)); - } + _staged.Clear(); + OnPropertyChanged(nameof(Staged)); _detailContext = null; _commitMessage = string.Empty; @@ -1210,10 +1198,10 @@ namespace SourceGit.ViewModels private bool _isCommitting = false; private bool _useAmend = false; private bool _canCommitWithPush = false; - private List _unstaged = null; - private List _staged = null; - private List _selectedUnstaged = null; - private List _selectedStaged = null; + private List _unstaged = []; + private List _staged = []; + private List _selectedUnstaged = []; + private List _selectedStaged = []; private int _count = 0; private object _detailContext = null; private string _commitMessage = string.Empty;