Skip to content

Commit 15e04a7

Browse files
committed
Updated to return both title and rootfolder name if not the same
1 parent 52ac2d9 commit 15e04a7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Commands/Base/Completers/ListNameCompleter.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@
55
using System.Management.Automation;
66
using System.Management.Automation.Language;
77
using Microsoft.SharePoint.Client;
8+
using PnP.Framework.Extensions;
9+
using PnP.Framework.Provisioning.Model.Drive;
810

911
namespace PnP.PowerShell.Commands.Base.Completers
1012
{
1113
public sealed class ListNameCompleter : PnPArgumentCompleter
1214
{
1315
protected override IEnumerable<CompletionResult> GetArguments(string commandName, string parameterName, string wordToComplete, CommandAst commandAst, IDictionary fakeBoundParameters)
1416
{
15-
IEnumerable<List> result = PnPConnection.Current.Context.LoadQuery(PnPConnection.Current.Context.Web.Lists.Include(list => list.Title));
17+
List<CompletionResult> arguments = new List<CompletionResult>();
18+
IEnumerable<List> result = PnPConnection.Current.Context.LoadQuery(PnPConnection.Current.Context.Web.Lists.Include(list => list.Title, list => list.RootFolder.Name));
1619
PnPConnection.Current.Context.ExecuteQueryRetry();
17-
foreach (var list in result.Where(l => l.Title.StartsWith(wordToComplete, StringComparison.InvariantCultureIgnoreCase)))
20+
foreach (var list in result.Where(l => l.Title.StartsWith(wordToComplete, StringComparison.InvariantCultureIgnoreCase) || l.RootFolder.Name.StartsWith(wordToComplete, StringComparison.InvariantCultureIgnoreCase)))
1821
{
19-
yield return new CompletionResult(list.Title);
20-
22+
if (list.RootFolder.Name != list.Title)
23+
{
24+
arguments.Add(new CompletionResult(list.RootFolder.Name));
25+
}
26+
arguments.Add(new CompletionResult(list.Title));
2127
}
22-
28+
return arguments.OrderBy(l => l.CompletionText);
2329
}
2430
}
2531
}

0 commit comments

Comments
 (0)