theia icon indicating copy to clipboard operation
theia copied to clipboard

Terminal improperly handles paste events (Linux)

Open colin-grant-work opened this issue 3 years ago • 1 comments

Bug Description:

In the Electron application on Linux, a terminal will inappropriately handle a paste command directed at the navigator. I cannot reproduce the behavior on MacOS.

Steps to Reproduce:

  1. Open the navigator widget.
  2. Open a terminal widget and focus it.
  3. Use the context menu copy command on a file node in the navigator tree
  4. Use the context menu paste command on a folder node in the navigator tree
  5. Observe that the URI of the file is pasted in the terminal widget, and the file is not pasted in the folder.

Additional Information

The problem seems due to our use of the document.execCommand API. When the terminal widget is focused, it creates a textarea element to handle input, and when we use the execCommand method to execute a paste action, the textarea is prioritized to handle the event since it is editable, and xterm's event handler calls stopPropagation. Setting the contenteditable property on the navigator widget's node to 'true' allows it to be prioritized over the terminal's input and fixes the bad behavior, but doesn't seem like the right move.

  • Operating System: Ubuntu 20.04 & RHEL7, Electron application
  • Theia Version: master (37ed897594a709d7e0a10d3db4c3bba85f00878a)

colin-grant-work avatar Feb 08 '22 18:02 colin-grant-work

Related: https://github.com/eclipse-theia/theia/issues/2171

tsmaeder avatar Jan 04 '24 15:01 tsmaeder