Skip to content

Make ad-hoc fixes for issues found out while using the module #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2023
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