Skip to content

cut multiline output inserts linebreak on paste #517

Closed

Description

Linebreaks appear to be inserted into screen output at width of buffer. Below, the console width is where the first line is cut off in the actual section.

# make sure console width is less than the width of this line
PS C:\Users\slee\repos\PowerShell> Write-Host "this is a long sentence that shouldn't have any linebreaks"
this is a long sentence that shouldn't have any linebreaks
# cut and paste the sentence above

Expected

PS C:\Users\slee\repos\PowerShell> "this is a long sentence that shouldn't have any linebreaks"

Actual

PS C:\Users\slee\repos\PowerShell> "this is a long se
>> ntence that shouldn't have any linebreaks"
PS C:\Users\slee\repos\PowerShell> $psversiontable

Name                           Value
----                           -----
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
CLRVersion
PSEdition                      Core
PSVersion                      6.0.0-alpha
GitCommitId                    v6.0.0-alpha.17
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0

Activity

  1. lzybkr commented on Mar 11, 2017

    @lzybkr
    Contributor

    I have work in progress that should fix this.

    In the current renderer, fixing this is impossible - I'm using apis below where conhost can infer anything about where line breaks are, this is done for performance, but is not portable.

    In the new renderer, I'm writing out a single string using an api like Console.WriteLine - the string has escape sequences in it for coloring. This means conhost can infer the line breaks correctly.

  2. MaximoTrinidad commented on Oct 1, 2017

    @MaximoTrinidad

    OK! So, we are with PowerShell Core v6.0.0-beta.7. We can't rely on the editor to do the magic when in fact the Module PSReadline is still having issues.

    There are third-party editors, like SAPIEN Technologies PrimalScript, out there that can add the PowerShell Core console and use it to run the PowerShell Core Scripts.

    So, here are some behavior I found:

    1. VS Code works fine using both the PowerShell Integrated Console and the RunCode extension.
    2. Copy/Paste from Any Editor straight to the PSCore console breaks (in both Windows and Linux) only if: (see below)
    :
    }
    else
    }
    :
    
    1. Now, in PrimalScript editor, PSReadLine module seems to work in Windows but not when connected to Linux PowerShell Core console. Only works if I remove the PSReadline module in both Windows and Linux.

    I think this is an issue that need some attention!

    Is there still a plan to correct it?
    :)

  3. lzybkr commented on Oct 3, 2017

    @lzybkr
    Contributor

    Maximo Trinidad (@MaximoTrinidad) - your comment unrelated to this issue - you open a new one if you want.

    That said, pasting with Ctrl+v avoids this issue. Today that only works in Windows PowerShell, but I have changes in the ansi_render branch to support Ctrl+v in PowerShell Core on Windows. I don't know how to implement that functionality on Linux/Mac.

    There may be some other heuristics we could use, e.g. detecting paste, assuming humans don't type as fast as pasting, but that has been a low priority item because Ctrl+v is a better experience anyway (much, much faster!)

    The alternative before PSReadline was to always require an empty line and I'm not a fan of that approach.

  4. lzybkr commented on Oct 16, 2017

    @lzybkr
    Contributor

    I believe this is fixed in #561.

    I'll publish a pre-release version to the PowerShell Gallery as soon as they support pre-releases.

    If you'd like to try a fix before that, you can build the lastest yourself from the master branch, or
    grab a build from AppVeyor like this one.

    Note the version number is now 2.0, so be sure to copy the contents to \PSReadLine\2.0.

  5. vors commented on Oct 23, 2017

    @vors
    Contributor

    Verified, this is fixed

  6. vors commented on Oct 23, 2017

    @vors
    Contributor

    Jason Shirk (@lzybkr) any reason to do a pre-release instead of a normal one?

  7. lzybkr commented on Oct 23, 2017

    @lzybkr
    Contributor

    Sure, it's not release quality yet. A couple of examples - my attempt to fix CJK broke use of screen in a big way and posh-git in a small way. I know of one issue where PowerShell crashes, and there are some minor artifacts during rendering.

    I think there are more good things coming soon, I just received a PR to handle redirected input, a common problem.

  8. lzybkr commented on Nov 4, 2017

    @lzybkr
    Contributor

    I'll have an official prerelease build out next week if you want to verify this is fixed, otherwise you can grab a build out of appveyor here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions