Skip to content
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
1 change: 1 addition & 0 deletions .vsts-ci/releaseBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ stages:
*.ps1xml
**\*.dll
!System.Runtime.InteropServices.RuntimeInformation.dll
!Microsoft.PowerShell.Pager.dll
useMinimatch: true

# Replace the *.psm1, *.ps1, *.psd1, *.dll files with the signed ones
Expand Down
2 changes: 1 addition & 1 deletion MockPSConsole/MockPSConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.1.0-rc.2" />
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions PSReadLine.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ task LayoutModule BuildPolyfiller, BuildMainModule, {

$binPath = "PSReadLine/bin/$Configuration/$Framework/publish"
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine2.dll $targetDir
Copy-Item $binPath/Microsoft.PowerShell.Pager.dll $targetDir

if (Test-Path $binPath/System.Runtime.InteropServices.RuntimeInformation.dll) {
Copy-Item $binPath/System.Runtime.InteropServices.RuntimeInformation.dll $targetDir
Expand Down
39 changes: 2 additions & 37 deletions PSReadLine/Completion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,17 +422,15 @@ private static string HandleNewlinesForPossibleCompletions(string s)
return s;
}

private class Menu
private class Menu : DisplayBlockBase
{
internal PSConsoleReadLine Singleton;
internal int Top;

internal int PreviousTop;
internal int ColumnWidth;
internal int BufferLines;
internal int Rows;
internal int Columns;
internal int ToolTipLines;

internal Collection<CompletionResult> MenuItems;
internal CompletionResult CurrentMenuItem => MenuItems[CurrentSelection];
internal int CurrentSelection;
Expand Down Expand Up @@ -701,39 +699,6 @@ public void MoveN(int n)
CurrentSelection += MenuItems.Count;
}
}

private void MoveCursorDown(int cnt)
{
IConsole console = Singleton._console;
while (cnt-- > 0)
{
console.Write("\n");
}
}

private void AdjustForPossibleScroll(int cnt)
{
IConsole console = Singleton._console;
var scrollCnt = console.CursorTop + cnt + 1 - console.BufferHeight;
if (scrollCnt > 0)
{
Top -= scrollCnt;
_singleton._initialY -= scrollCnt;
_savedCursorTop -= scrollCnt;
}
}

private int _savedCursorLeft;
private int _savedCursorTop;

public void SaveCursor()
{
IConsole console = Singleton._console;
_savedCursorLeft = console.CursorLeft;
_savedCursorTop = console.CursorTop;
}

public void RestoreCursor() => Singleton._console.SetCursorPosition(_savedCursorLeft, _savedCursorTop);
}

private Menu CreateCompletionMenu(Collection<CompletionResult> matches)
Expand Down
51 changes: 51 additions & 0 deletions PSReadLine/DisplayBlockBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/

using System;
using Microsoft.PowerShell.Internal;

namespace Microsoft.PowerShell
{
public partial class PSConsoleReadLine
{
private class DisplayBlockBase
{
internal PSConsoleReadLine Singleton;
internal int Top;

protected void MoveCursorDown(int cnt)
{
IConsole console = Singleton._console;
while (cnt-- > 0)
{
console.Write("\n");
}
}

protected void AdjustForPossibleScroll(int cnt)
{
IConsole console = Singleton._console;
var scrollCnt = console.CursorTop + cnt + 1 - console.BufferHeight;
if (scrollCnt > 0)
{
Top -= scrollCnt;
_singleton._initialY -= scrollCnt;
_savedCursorTop -= scrollCnt;
}
}

private int _savedCursorLeft;
private int _savedCursorTop;

public void SaveCursor()
{
IConsole console = Singleton._console;
_savedCursorLeft = console.CursorLeft;
_savedCursorTop = console.CursorTop;
}

public void RestoreCursor() => Singleton._console.SetCursorPosition(_savedCursorLeft, _savedCursorTop);
}
}
}
Loading