Copy/Paste does not work, but Drag/Drop always works

Issue #216 new
Anthony Missico created an issue

Unable to copy and paste from the code editor window, but I can always drag/drop the text.

I do not have duplication steps, but it happens during every session.

  <entry>
    <record>1551</record>
    <time>2019/11/14 19:13:36.518</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.&#x000D;&#x000A;Parameter name: index&#x000D;&#x000A;   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)&#x000D;&#x000A;   at PowerShellTools.Repl.ReplWindow.ClearInput()&#x000D;&#x000A;   at PowerShellTools.Repl.ReplWindow.PreEditorCommandFilterExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at PowerShellTools.Repl.ReplWindow.CommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.Undo.UndoManagerCommandFilter.Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.IntellisenseCommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.BraceCompletionCommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   at Microsoft.VisualStudio.Editor.Implementation.CommandHandlerServiceAdapter.&lt;&gt;c__DisplayClass17_0.&lt;Exec&gt;g__executeNextCommandTarget|1()&#x000D;&#x000A;   at Microsoft.VisualStudio.Commanding.CommandHandlerExtensions.ExecuteCommand[T](ICommandHandler commandHandler, T args, Action nextCommandHandler, CommandExecutionContext executionContext)&#x000D;&#x000A;   at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.&lt;&gt;c__DisplayClass13_1`1.&lt;Execute&gt;b__1()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate`1 exceptionFilter)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

Same, but added new-lines

  <entry>
    <record>1551</record>
    <time>2019/11/14 19:13:36.518</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.&#x000D;&#x000A;Parameter name: index&#x000D;&#x000A;   
 at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)&#x000D;&#x000A;   
 at PowerShellTools.Repl.ReplWindow.ClearInput()&#x000D;&#x000A;   
 at PowerShellTools.Repl.ReplWindow.PreEditorCommandFilterExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at PowerShellTools.Repl.ReplWindow.CommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.Undo.UndoManagerCommandFilter.Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.IntellisenseCommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.BraceCompletionCommandFilter.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid&amp; pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Editor.Implementation.CommandHandlerServiceAdapter.&lt;&gt;c__DisplayClass17_0.&lt;Exec&gt;g__executeNextCommandTarget|1()&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Commanding.CommandHandlerExtensions.ExecuteCommand[T](ICommandHandler commandHandler, T args, Action nextCommandHandler, CommandExecutionContext executionContext)&#x000D;&#x000A;   
 at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.&lt;&gt;c__DisplayClass13_1`1.&lt;Execute&gt;b__1()&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate`1 exceptionFilter)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   
 at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
  </entry>

Microsoft Visual Studio 2019 version: 16.0.29505.95

PoshTools 5.1.0

PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Comments (8)

  1. Adam Driscoll

    I just want to make sure. This is happening in the code editor and not the PowerShell Interactive Window?

  2. Anthony Missico Account Deactivated reporter

    I believe so. It is hard to verify. When I look at clipboard history, it is always correct, but never pastes as the value shown.

    I am not sure the log entry above is related, I provided just in case. Even if I do not get the error in VS activity log, the problem still happens. It has been happening for long time. I thought it would be resolved with the latest updates. Also, I though with $dte being null it would fail. However, I can still copy/paste properly when I open VS and $dte is not initialize.

    When I created this, the interactive window was working as expected, the code window was failing.

  3. Anthony Missico Account Deactivated reporter

    My problem now is that I can copy and paste outside of Visual Studio properly, but when I switch to Visual Studio and paste, the value is incorrect.

    1. The value “environment” is on the clipboard.
    2. I copy “status” from a file-difference-viewer and paste the value “status” into plain-text-editor as expected.
    3. I switch to VS with PowerShell project and paste, I get “environment” that was on the clipboard last, not expected.
    4. I switch back to plain-text-editor and paste, I get “enviornment” that was just pasted in VS, not expected.
    5. Using the clipboard viewer “Hot Copy Paste”.
    6. I copy anything, like this line.
    7. I switch to Visual Studio, a clipboard entry is created with “environment” without me doing anything.

  4. Adam Driscoll

    I just reproduced this behavior. I haven’t pinned it down yet because I’m not seeing it happen every time. There is a keyboard filter for the Interactive Window that might be causing issues. The issue with the Interactive Window is that Ctrl+C means two different things when it comes to a terminal. Copy and Stop Execution. The keyboard filter shouldn’t be applying to the regular editor window but maybe there is something I’m missing.

    I’ll let you know when I nail this down. Just to be clear, you’re not seeing the exception any more?

  5. Anthony Missico Account Deactivated reporter

    Correct. Not seeing the exception.

    However, I think I know what the exception is from. I noticed this behavior, but have not had the opportunity to do it again, so the following is from memory.

    I believe it is caused when you have multiple lines in the interactive window, the prompt does not display, you place the cursor into one of those lines, then press Esc.

  6. Anthony Missico Account Deactivated reporter

    Here is something very interesting.

    1. The interactive window has a blank line above the prompt.
    2. I cannot copy the path of a file. I tried via the tab and via the solution explorer.
    3. I open “Hot Copy Paste” and there is no new entry
    4. I thought that maybe clearing the interactive window would help
    5. I clicked the ‘Clear Screen’ glyph.
    6. I was then able to copy the path through the solution explorer.
    7. Switch from VS to other apps and back to VS did not change the clipboard

  7. Anthony Missico Account Deactivated reporter

    Verified / Duplicated Exception

    I believe it is caused when you have multiple lines in the interactive window, the prompt does not display, you place the cursor into one of those lines, then press Esc.<<

    1. Interactive Window contains multiple lines, but the prompt does not display.
    2. Place the cursor in one of those lines.
    3. Press Esc

  8. Log in to comment