Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit c71ed32

Browse files
committed
Define TabExpansion function in NuGet PowerShell console.
1 parent 5e6013e commit c71ed32

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageManagementConsoleHost.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void InitPowerShell()
126126
powerShellHost.SetRemoteSignedExecutionPolicy();
127127
UpdateFormatting();
128128
RedefineClearHostFunction();
129+
DefineTabExpansionFunction();
129130
UpdateWorkingDirectory();
130131
}
131132

@@ -163,6 +164,15 @@ void RedefineClearHostFunction()
163164
powerShellHost.ExecuteCommand(command);
164165
}
165166

167+
void DefineTabExpansionFunction()
168+
{
169+
string command =
170+
"function TabExpansion($line, $lastWord) {" +
171+
" return New-Object PSObject -Property @{ NoResult = $true }" +
172+
"}";
173+
powerShellHost.ExecuteCommand(command);
174+
}
175+
166176
void WriteInfoBeforeFirstPrompt()
167177
{
168178
WriteNuGetVersionInfo();

src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
using System;
2020
using System.Collections.Generic;
21+
using System.Linq;
2122
using ICSharpCode.PackageManagement;
2223
using ICSharpCode.PackageManagement.Design;
2324
using ICSharpCode.PackageManagement.EnvDTE;
2425
using ICSharpCode.PackageManagement.Scripting;
2526
using ICSharpCode.Scripting;
26-
using ICSharpCode.Scripting.Tests.Utils;
2727
using NuGet;
2828
using NUnit.Framework;
2929
using PackageManagement.Tests.Helpers;
@@ -673,5 +673,18 @@ public void SetDefaultRunspace_AfterHostIsRun_SetsDefaultRunspaceOnPowershellHos
673673

674674
Assert.IsTrue(powerShellHost.IsSetDefaultRunspaceCalled);
675675
}
676+
677+
[Test]
678+
public void Run_ConsoleExitsOnFirstRead_TabExpansionFunctionDefined()
679+
{
680+
CreateHost();
681+
RunHost();
682+
683+
string partialExecutedScript = "function TabExpansion";
684+
685+
bool executed = powerShellHost.AllCommandsPassedToExecuteCommand.Any(command => command.Contains(partialExecutedScript));
686+
687+
Assert.IsTrue(executed);
688+
}
676689
}
677690
}

0 commit comments

Comments
 (0)