Skip to content

Commit af69ccb

Browse files
authored
Make ad-hoc fixes for issues found out while using the module (#23)
1 parent dbd89af commit af69ccb

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/CustomHandlers/GitNode.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ internal override SuggestionPackage Predict(
269269
}
270270
}
271271

272+
string activeBranch = repoInfo.ActiveBranch;
273+
string defaultBranch = repoInfo.DefaultBranch;
274+
272275
if (originBranches is not null)
273276
{
274277
// The 'origin' remote exists, so do a smart check to find those local branches
@@ -281,7 +284,7 @@ internal override SuggestionPackage Predict(
281284
foreach (string branch in localBranches)
282285
{
283286
if (branch.StartsWith(filter, StringComparison.Ordinal) &&
284-
branch != repoInfo.ActiveBranch)
287+
branch != activeBranch)
285288
{
286289
ret ??= new List<string>();
287290
ret.Add(branch);
@@ -296,8 +299,8 @@ internal override SuggestionPackage Predict(
296299
foreach (string branch in repoInfo.Branches)
297300
{
298301
if (branch.StartsWith(filter, StringComparison.Ordinal) &&
299-
branch != repoInfo.ActiveBranch &&
300-
branch != repoInfo.DefaultBranch)
302+
branch != activeBranch &&
303+
branch != defaultBranch)
301304
{
302305
ret ??= new List<string>();
303306
ret.Add(branch);
@@ -385,10 +388,11 @@ internal override SuggestionPackage Predict(
385388
private List<string>? PredictArgument(string filter, RepoInfo repoInfo, bool excludeActiveBranch)
386389
{
387390
List<string>? ret = null;
391+
string activeBranch = repoInfo.ActiveBranch;
388392

389393
foreach (string localBranch in repoInfo.Branches)
390394
{
391-
if (excludeActiveBranch && localBranch == repoInfo.ActiveBranch)
395+
if (excludeActiveBranch && localBranch == activeBranch)
392396
{
393397
continue;
394398
}
@@ -428,7 +432,7 @@ internal override SuggestionPackage Predict(
428432

429433
if (textAtCursor is not null && textAtCursor.StartsWith('-'))
430434
{
431-
const string forceWithLease = "--force-with-lease ";
435+
const string forceWithLease = "--force-with-lease";
432436
if (forceWithLease.StartsWith(textAtCursor, StringComparison.Ordinal))
433437
{
434438
hasAutoFill = true;

src/CustomHandlers/GitRepoInfo.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ internal List<RemoteInfo> Remotes
7575
internal void NeedCheckForUpdate()
7676
{
7777
_checkForUpdate = true;
78-
foreach (var remote in _remotes!)
78+
if (_remotes is null)
79+
{
80+
return;
81+
}
82+
83+
foreach (var remote in _remotes)
7984
{
8085
remote.NeedCheckForUpdate();
8186
}

0 commit comments

Comments
 (0)