Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/CustomHandlers/GitNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<string>();
ret.Add(branch);
Expand All @@ -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<string>();
ret.Add(branch);
Expand Down Expand Up @@ -385,10 +388,11 @@ internal override SuggestionPackage Predict(
private List<string>? PredictArgument(string filter, RepoInfo repoInfo, bool excludeActiveBranch)
{
List<string>? ret = null;
string activeBranch = repoInfo.ActiveBranch;

foreach (string localBranch in repoInfo.Branches)
{
if (excludeActiveBranch && localBranch == repoInfo.ActiveBranch)
if (excludeActiveBranch && localBranch == activeBranch)
{
continue;
}
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/CustomHandlers/GitRepoInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ internal List<RemoteInfo> Remotes
internal void NeedCheckForUpdate()
{
_checkForUpdate = true;
foreach (var remote in _remotes!)
if (_remotes is null)
{
return;
}

foreach (var remote in _remotes)
{
remote.NeedCheckForUpdate();
}
Expand Down