Skip to content

Pasting to PSIT strips characters breaking filepaths, and is missing terminalShellType #3260

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

Closed
ninmonkey opened this issue Mar 27, 2021 · 7 comments
Labels
Bug: VS Code Bugs in VS Code itself. Resolution-External Will close automatically.

Comments

@ninmonkey
Copy link

System Details

System Details Output (Click to Expand)
### VSCode version: 1.55.0-insider d06d2f1d6245ce00b1c36a9cd81a9087d225173e x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.2
PSEdition                      Core
GitCommitId                    7.1.2
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

### Maybe Related Modules

> Get-Module Pansies, PSReadLine, EditorServicesCommandSuite, *Edit

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     1.0.0      beta3      EditorServicesCommandSuite
Script     2.1.0                 Pansies
Script     0.2.0                 PowerShellEditorServices.Commands
Binary     0.2.0                 PowerShellEditorServices.VSCode
Script     2.2.0      beta2      PSReadLine

Issue Description

  1. Pasting ctrl+v to the terminal has encoding errors in code-insider but not code
  2. the default keybinding behavior to ignore ctrl+v when the term is pwsh is broken in code-insider but not code
  3. Paste breaks when the text starts with "
  4. terminalShellType is missing in code-insider

Expected Behavior

  1. Paste text without modifying the text

Actual Behavior

VS Code with some codepoints incorrectly pastes filenames - 2021-03-24

Build Mutates Text
code No
code-insider Yes

occurs on ms-vscode.powershell and ms-vscode.powershell-preview

There is no terminalShellType property in code-insider

missing terminalShellType in code-insider

Paste breaks when it starts with a double quote "

visual-04 - 2021-03-27

Breaks on Paste

"C:\Users\color names 🖥️ console Ansi 🎨 2021-03-23.ps1"

Works:

'C:\Users\color names 🖥️ console Ansi 🎨 2021-03-23.ps1'
Methods that work around the problem
  1. Use (get-clipboard), or
  2. unbind code-insider keybindings for ctrl+v
The Default keybinding condition:
{
    "key": "ctrl+v",
    "command": "workbench.action.terminal.sendSequence",
    "when": "terminalFocus && !accessibilityModeEnabled && terminalShellType == 'pwsh'",
    "args": {
        "text": "\u0016"
    }
}

Attached Logs

PowershellEditorServices-2021-03-27.log

Profile

Note: I have a customized terminal, but a few reasons make me think that's not the cause

  • the bug does not occur on regular code
  • the bug does not occur using windowsterminal
  • it occurs on both powershell extensions
  • the missing property/key name in code-insider
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 27, 2021
@ninmonkey
Copy link
Author

ninmonkey commented Mar 27, 2021

Maybe related?

The PSIT is not calculating widths property when ANSI escapes/nonvisible characters are used (like color).
image

This time it's not code vs code-insiders, it's the extension verses none:

  • code and code-insiders - broken using PSIT
  • code and code-insiders - working when using pwsh (ie: not the integrated debugger term)

image

@SeeminglyScience
Copy link
Collaborator

  1. Paste breaks when the text starts with "

Do you have the PSRL key handler that tries to auto close quotes? Those tend to wreak havoc when the terminal host pretends to paste with input sequences.

  1. terminalShellType is missing in code-insider

Is it missing for just the PSIC? Or is it also missing for a non-extension pwsh terminal?

@SeeminglyScience
Copy link
Collaborator

Maybe related?

The PSIT is not calculating widths property when ANSI escapes/nonvisible characters are used (like color).

Here's the issue to track for that: PowerShell/PowerShellEditorServices#840

@SydneyhSmith
Copy link
Collaborator

Thanks @ninmonkey thanks for testing all of that and providing a very detailed report-- we really appreciate that...given that this is only reproducing in code-insiders and not code it appears to be a bug with code insiders

@SydneyhSmith SydneyhSmith added Resolution-External Will close automatically. Bug: VS Code Bugs in VS Code itself. and removed Needs: Triage Maintainer attention needed! labels Mar 30, 2021
@ghost ghost closed this as completed Mar 30, 2021
@ninmonkey
Copy link
Author

ninmonkey commented Apr 11, 2021

@SydneyhSmith It is now failing in regular code. It doesn't occur on ascii filepaths, so that won't show up as a failure.

Somewhere an encode or decode error is happening with the ignore option on, so it just stripped the errors (making the path invalid)

color🎨test.ps1 becomes colortest.ps1

Results

in VS Code

  • Ok - (get-clipboard) pastes the path correctly
  • Bug ctrl+v in PSIT always breaks

in WindowsTerminal

  • Ok - (get-clipboard)
  • Ok - ctrl+v

Steps to reproduce

PS> 'text' | Set-Content 'temp:\color🎨test.ps1'
PS> code (gi Temp:\color🎨test.ps1 -ea stop)

Then copy the path with the UI

image

image

@SeeminglyScience

Do you have the PSRL key handler that tries to auto close quotes? Those tend to wreak havoc when the terminal host pretends to paste with input sequences.

No. I grepped for PSReadline in my profile and module and found nothing.

  1. Is there a command to double check that there aren't any being loaded by other modules?
  2. Is there a way to start without non-default modules loaded? To have a clean test environment?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 11, 2021
@ninmonkey
Copy link
Author

ninmonkey commented Apr 11, 2021

update: Toggling this keybind on/off toggles the bug on and off.

    {
        "key": "ctrl+v", // fixes a lot of paste problems for pwsh at least
        "command": "-workbench.action.terminal.paste",
        "when": "terminalFocus"
    },

Note

The video has PSReadline beta enabled, but

  • the behavior is the same as before installing the beta
  • paste with the beta on works for all cases except when vs code has a keybinding for ctrl+v

vscode-powershell - paste command breaks paste - 2021-04-11

@SeeminglyScience

  1. terminalShellType is missing in code-insider

Is it missing for just the PSIC? Or is it also missing for a non-extension pwsh terminal?

I could not find terminalShellType on any of the 3 tests on regular code

image

image

@ninmonkey
Copy link
Author

Closing summary: This seems to be an external bug / caused by PSReadLine itself.

Test Case: Error

  1. copy a path to your clipboard that uses surrogate pairs when encoded as utf16, for example 🖥️
  2. type gi ' then paste the path

File not found

Test Case: Working

  1. run Remove-Module PSReadLine
  2. Paste like the first test

Get-Item does find the file

It doesn't seem to matter whether the 3 encodings are set to utf16le vs utf8
[console]::InputEncoding, [console]::OutputEncoding, $OutputEncoding

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label May 18, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: VS Code Bugs in VS Code itself. Resolution-External Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants