diff --git a/src/CustomHandlers/GitNode.cs b/src/CustomHandlers/GitNode.cs index f88cdf7..bfa8a24 100644 --- a/src/CustomHandlers/GitNode.cs +++ b/src/CustomHandlers/GitNode.cs @@ -269,6 +269,9 @@ internal override SuggestionPackage Predict( } } + string activeBranch = repoInfo.ActiveBranch; + string defaultBranch = repoInfo.DefaultBranch; + if (originBranches is not null) { // The 'origin' remote exists, so do a smart check to find those local branches @@ -281,7 +284,7 @@ internal override SuggestionPackage Predict( foreach (string branch in localBranches) { if (branch.StartsWith(filter, StringComparison.Ordinal) && - branch != repoInfo.ActiveBranch) + branch != activeBranch) { ret ??= new List(); ret.Add(branch); @@ -296,8 +299,8 @@ internal override SuggestionPackage Predict( foreach (string branch in repoInfo.Branches) { if (branch.StartsWith(filter, StringComparison.Ordinal) && - branch != repoInfo.ActiveBranch && - branch != repoInfo.DefaultBranch) + branch != activeBranch && + branch != defaultBranch) { ret ??= new List(); ret.Add(branch); @@ -385,10 +388,11 @@ internal override SuggestionPackage Predict( private List? PredictArgument(string filter, RepoInfo repoInfo, bool excludeActiveBranch) { List? ret = null; + string activeBranch = repoInfo.ActiveBranch; foreach (string localBranch in repoInfo.Branches) { - if (excludeActiveBranch && localBranch == repoInfo.ActiveBranch) + if (excludeActiveBranch && localBranch == activeBranch) { continue; } @@ -428,7 +432,7 @@ internal override SuggestionPackage Predict( if (textAtCursor is not null && textAtCursor.StartsWith('-')) { - const string forceWithLease = "--force-with-lease "; + const string forceWithLease = "--force-with-lease"; if (forceWithLease.StartsWith(textAtCursor, StringComparison.Ordinal)) { hasAutoFill = true; diff --git a/src/CustomHandlers/GitRepoInfo.cs b/src/CustomHandlers/GitRepoInfo.cs index ace17c5..75b35d9 100644 --- a/src/CustomHandlers/GitRepoInfo.cs +++ b/src/CustomHandlers/GitRepoInfo.cs @@ -75,7 +75,12 @@ internal List Remotes internal void NeedCheckForUpdate() { _checkForUpdate = true; - foreach (var remote in _remotes!) + if (_remotes is null) + { + return; + } + + foreach (var remote in _remotes) { remote.NeedCheckForUpdate(); }