Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when pasting code #1346

Closed
ma3yta opened this issue Feb 10, 2020 · 4 comments
Closed

Error when pasting code #1346

ma3yta opened this issue Feb 10, 2020 · 4 comments

Comments

@ma3yta
Copy link

ma3yta commented Feb 10, 2020

Environment

Windows build number: 
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19559.0 Microsoft Windows NT 10.0.19559.0
Windows Terminal version : 0.8.10261.0

The bug is that PSReadline is trying to change the contents off the top of the screen, but Terminal doesn't have any. PSReadline cannot handle the screen buffer size being the same as the viewport size.

Steps to reproduce

  1. open windows terminal -> powershell session
  2. copy and paste code into wt
$hotkeysFile = "$home\hotkeys.ahk"
$keys = @"
#SingleInstance, Force
; https://www.autohotkey.com/docs/Hotkeys.htm
; # win ! alt ^ control + shift 
^!t:: run wt, return
#+p:: run powershell, return
#n:: run notepad++, return
#c:: run code, return
#v:: run devenv, return
#f:: run firefox, return
#e:: run fman, return
#t:: run wt, return
#a:: run "sudo" "wt.exe", return
Space:: send {Space down}
	sleep 0.001 
	send {Space up}
	return
Space & t:: run wt, return
#b::
{ SendMode Input
  Run, ms-settings:bluetooth
  WinWaitActive, Settings
  Sleep 300
  Send,{Tab}{Space}
  WinClose, A
  return
}
; AutoHotkey Media Keys
^Down:: 
	Send {Media_Play_Pause}
	return
^Left:: 
	Send {Media_Prev}
	return
^Right:: 
	Send {Media_Next}
	return
^NumpadMult:: 
	Send {Volume_Mute}
	return
^NumpadAdd:: 
	Send {Volume_Up}
	return
^NumpadSub:: 
	Send {Volume_Down}
	return
^!p::Pause ; Pause script with Ctrl+Alt+P
^!s::Suspend ; Suspend script with Ctrl+Alt+S
^!r::Reload ; Reload script with Ctrl+Alt+R
^!q::ExitApp ; Exit script with Ctrl+Alt+Q
"@

image

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
 Space { V o l u m e _ D o w n } Enter
 Tab r e t u r n Enter
 ^ ! p : : P a u s e Space ; Space P a u s e Space s c r i p t Space w i t h Space C t r l + A l t + P Enter
 ^ ! s : : S u s p e n d Space ; Space S u s p e n d Space s c r i p t Space w i t h Space C t r l + A l t + S Enter
 ^ ! r : : R e l o a d Space ; Space R e l o a d Space s c r i p t Space w i t h Space C t r l + A l t + R Enter
 ^ ! q : : E x i t A p p Space ; Space E x i t Space s c r i p t Space w i t h Space C t r l + A l t + Q Enter
 " @

Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -6.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------

Expected behavior

All should work fine like in regular Powershell terminal.

Actual behavior

Error in the console Oops, something went wrong

@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Feb 10, 2020
@DHowett-MSFT
Copy link

This happens if the buffer size == the viewport size and the input is taller than the viewport.

@daxian-dbw
Copy link
Member

This was fixed in recent versions of PSReadLine. Check out the pinned issue #1306

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Feb 12, 2020
@ma3yta
Copy link
Author

ma3yta commented Feb 13, 2020

@daxian-dbw
I got the same error with PSReadLine 2.0.0-beta3 installed.

Get-InstalledModule -Name "PSReadLine"

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
2.0.0-beta3          PSReadLine                          PSGallery            Great command line editing in the PowerShell console host
                                                                                                                                                   
❯ Get-Module
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     2.0.379    oh-my-posh                          {Get-ComputerName, Get-FormattedRootLocation, Get-FullPath, Get-ShortPath...}
Script     1.4.6      PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     0.7.3      posh-git                            {Add-PoshGitToProfile, Add-SshKey, Enable-GitColors, Expand-GitCommand...}
Script     2.2.3      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}

@DHowett-MSFT
Copy link

beta3 may not count as "recent versions". There have been 3 betas, 2 RCs and one GA update since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants