Skip to content

Commit 5c69c7d

Browse files
committed
Merge pull request #135 from PowerShell/daviwil/minor-fixes
A few minor fixes for the 0.4.0 release
2 parents 527fb43 + dba7e97 commit 5c69c7d

File tree

8 files changed

+55
-71
lines changed

8 files changed

+55
-71
lines changed

src/PowerShellEditorServices.Host.x86/Microsoft.PowerShell.EditorServices.Host.DebugAdapter.x86.cmd

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/PowerShellEditorServices.Host.x86/PowerShellEditorServices.Host.x86.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
<Compile Include="Properties\AssemblyInfo.cs" />
5454
</ItemGroup>
5555
<ItemGroup>
56-
<Content Include="Microsoft.PowerShell.EditorServices.Host.DebugAdapter.x86.cmd">
57-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58-
</Content>
5956
<None Include="..\PowerShellEditorServices.Host\App.config">
6057
<Link>App.config</Link>
6158
</None>

src/PowerShellEditorServices.Host/Microsoft.PowerShell.EditorServices.Host.DebugAdapter.cmd

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
</ItemGroup>
5555
<ItemGroup>
5656
<None Include="App.config" />
57-
<Content Include="Microsoft.PowerShell.EditorServices.Host.DebugAdapter.cmd">
58-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59-
</Content>
6057
</ItemGroup>
6158
<ItemGroup>
6259
<ProjectReference Include="..\..\submodules\PSScriptAnalyzer\Engine\ScriptAnalyzerEngine.csproj">

src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.nuspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
</metadata>
2222
<files>
2323
<file src="bin\$configuration$\$id$.exe" target="lib\net45\" />
24-
<file src="bin\$configuration$\$id$.DebugAdapter.cmd" target="content\" />
2524
<file src="..\PowerShellEditorServices.Host.x86\bin\$configuration$\$id$.x86.exe" target="lib\net45\" />
26-
<file src="..\PowerShellEditorServices.Host.x86\bin\$configuration$\$id$.DebugAdapter.x86.cmd" target="content\" />
2725
</files>
2826
</package>

src/PowerShellEditorServices.Host/Program.cs

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ class Program
1818
[STAThread]
1919
static void Main(string[] args)
2020
{
21+
#if DEBUG
22+
bool waitForDebugger =
23+
args.Any(
24+
arg =>
25+
string.Equals(
26+
arg,
27+
"/waitForDebugger",
28+
StringComparison.InvariantCultureIgnoreCase));
29+
30+
// Should we wait for the debugger before starting?
31+
if (waitForDebugger)
32+
{
33+
// Wait for 25 seconds and then continue
34+
int waitCountdown = 25;
35+
while (!Debugger.IsAttached && waitCountdown > 0)
36+
{
37+
Thread.Sleep(1000);
38+
waitCountdown--;
39+
}
40+
}
41+
#endif
42+
2143
string logPath = null;
2244
string logPathArgument =
2345
args.FirstOrDefault(
@@ -31,6 +53,23 @@ static void Main(string[] args)
3153
logPath = logPathArgument.Substring(9).Trim('"');
3254
}
3355

56+
LogLevel logLevel = LogLevel.Normal;
57+
string logLevelArgument =
58+
args.FirstOrDefault(
59+
arg =>
60+
arg.StartsWith(
61+
"/logLevel:",
62+
StringComparison.InvariantCultureIgnoreCase));
63+
64+
if (!string.IsNullOrEmpty(logLevelArgument))
65+
{
66+
// Attempt to parse the log level
67+
Enum.TryParse<LogLevel>(
68+
logLevelArgument.Substring(10).Trim('"'),
69+
true,
70+
out logLevel);
71+
}
72+
3473
bool runDebugAdapter =
3574
args.Any(
3675
arg =>
@@ -54,46 +93,8 @@ static void Main(string[] args)
5493
server = new LanguageServer();
5594
}
5695

57-
// Start the logger with the specified log path
58-
// TODO: Set the level based on command line parameter
59-
Logger.Initialize(logPath, LogLevel.Verbose);
60-
61-
#if DEBUG
62-
bool waitForDebugger =
63-
args.Any(
64-
arg =>
65-
string.Equals(
66-
arg,
67-
"/waitForDebugger",
68-
StringComparison.InvariantCultureIgnoreCase));
69-
70-
// Should we wait for the debugger before starting?
71-
if (waitForDebugger)
72-
{
73-
Logger.Write(LogLevel.Normal, "Waiting for debugger to attach before continuing...");
74-
75-
// Wait for 15 seconds and then continue
76-
int waitCountdown = 15;
77-
while (!Debugger.IsAttached && waitCountdown > 0)
78-
{
79-
Thread.Sleep(1000);
80-
waitCountdown--;
81-
}
82-
83-
if (Debugger.IsAttached)
84-
{
85-
Logger.Write(
86-
LogLevel.Normal,
87-
"Debugger attached, continuing startup sequence");
88-
}
89-
else if (waitCountdown == 0)
90-
{
91-
Logger.Write(
92-
LogLevel.Normal,
93-
"Timed out while waiting for debugger to attach, continuing startup sequence");
94-
}
95-
}
96-
#endif
96+
// Start the logger with the specified log path and level
97+
Logger.Initialize(logPath, logLevel);
9798

9899
FileVersionInfo fileVersionInfo =
99100
FileVersionInfo.GetVersionInfo(
@@ -102,8 +103,9 @@ static void Main(string[] args)
102103
Logger.Write(
103104
LogLevel.Normal,
104105
string.Format(
105-
"PowerShell Editor Services Host v{0} starting...",
106-
fileVersionInfo.FileVersion));
106+
"PowerShell Editor Services Host v{0} starting (pid {1})...",
107+
fileVersionInfo.FileVersion,
108+
Process.GetCurrentProcess().Id));
107109

108110
// Start the server
109111
server.Start().Wait();

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,15 @@ private void WritePromptToHost(Func<PSCommand, string> invokeAction)
905905
Environment.NewLine,
906906
false);
907907

908+
// Trim the '>' off the end of the prompt string to reduce
909+
// user confusion about where they can type.
910+
// TODO: Eventually put this behind a setting, #133
911+
promptString = promptString.TrimEnd(' ', '>', '\r', '\n');
912+
908913
// Write the prompt string
909914
this.WriteOutput(
910915
promptString,
911-
false);
916+
true);
912917
}
913918

914919
private void WritePromptWithRunspace(Runspace runspace)
@@ -974,7 +979,8 @@ private void OnDebuggerStop(object sender, DebuggerStopEventArgs e)
974979
null));
975980

976981
// Write out the debugger prompt
977-
this.WritePromptWithNestedPipeline();
982+
// TODO: Eventually re-enable this and put it behind a setting, #133
983+
//this.WritePromptWithNestedPipeline();
978984

979985
// Raise the event for the debugger service
980986
if (this.DebuggerStop != null)

test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ await this.powerShellContext.ExecuteScriptString(
7979
new string[] { Environment.NewLine },
8080
StringSplitOptions.None);
8181

82-
// The output should be 3 lines: the expected string,
83-
// an empty line, and the prompt string.
84-
Assert.Equal(3, normalOutputLines.Length);
82+
// The output should be 4 lines: the expected string, an
83+
// empty line, the prompt string, and another empty line.
84+
Assert.Equal(4, normalOutputLines.Length);
8585
Assert.Equal(
8686
TestOutputString,
8787
normalOutputLines[0]);

0 commit comments

Comments
 (0)