Vscode: TMux: Copy and paste commands not working on Mac OS

Created on 6 Apr 2017  ·  39Comments  ·  Source: microsoft/vscode

  • VSCode Version: 1.11.1
  • OS Version: 10.12.4

Steps to Reproduce:

  1. Highlight text and either use the copy keyboard shortcut or select the copy command from the edit menu.
  2. Attempt to paste the copied selection by either using the paste keyboard shortcut or select the paste command from the edit menu.
  3. The text does not paste

Additional Info:

  • Keyboard shortcuts are properly assigned
  • Cut command works but paste still does not work after cutting text
  • Disabling all extensions did not fix the issue
  • Using the command palette to select copy and paste also does not work
electron help wanted keybindings mac needs more info upstream

Most helpful comment

Is this perhaps a dup of #13366, which is an external issue described in electron repo https://github.com/electron/electron/issues/916 .

For short:

OS X's clipboard API requires the process to run in a UI session, which might not be true if you are using tmux.

You can mitigate this issue by following https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard#mac-os-x-pasteboard-access-under-tmux-and-screen

All 39 comments

Which keyboard layout are you using?

I am using the default keyboard layout. I have not made any changes.

Is the physical keyboard U.S. English?

Yes it is.

Is this perhaps a dup of #13366, which is an external issue described in electron repo https://github.com/electron/electron/issues/916 .

For short:

OS X's clipboard API requires the process to run in a UI session, which might not be true if you are using tmux.

You can mitigate this issue by following https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard#mac-os-x-pasteboard-access-under-tmux-and-screen

That is not the issue, I am launching the application from the applications list and I am not using screen or tmux.

Also experiencing this after upgrading to 1.11.2. Copy and paste don't work, neither from the keyboard nor the context menus, and I also launch via the applications list.

The same problem in 1.12.1 version on MacOS.

I believe this is an Electron issue - https://github.com/electron/electron/issues/9352

Does the description in there ring any bell? i.e. after restarting the app, does the clipboard start working again?

It is not woking after restarting the app. :(

I resolved it by rebooting my whole machine. A big hammer, to be sure, but
fortunately the problem hasn't reproduced since.

On Fri, May 5, 2017 at 12:24 PM Bo-Yi Wu notifications@github.com wrote:

It is not woking after restarting the app. :(


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/24112#issuecomment-299510697,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA15IDmX8jMeAzAXUIm3hykwqH84NIvhks5r201JgaJpZM4M178x
.

Same here (when trying to paste to command palette), but it just worked again after restarting VS Code.

Not sure how to reproduce it.

I revert the vs code version to 1.11.2 which is working version for me.

@appleboy

So it makes more sense that this might be an upstream issue :/

1.12 Release Note: In this release, we updated from Electron 1.4.x to 1.6.6.

UPDATE: Sorry I didn't notice that OP reported this issue before the release of 1.12

@hungys Yes.

I don't know why it is working after restart vscode app for you or anyone. This approach can't work with my mac OS 10.10.5.

@appleboy

I'm on macOS 10.12.4, FYI

Despite restarting somehow resolves it, my friends with the same OS version still experienced this issue frequently. While I found it hard to reproduce it.

To clarify, we only experienced this issue when trying to paste something to the command palette.

restarting the app does not help me, and I can repro in a variety of places, not just the command palette. I also regularly can not type in a new blank document. (macOS Sierra)

@colemickens

For the second issue, are you on 1.13-Insiders? check #26279

Here is an interesting comment from a different issue - https://github.com/Microsoft/vscode/issues/6884#issuecomment-241848994

This was indeed an OSX issue for me. The following worked:

launchctl stop com.apple.pboard
launchctl start com.apple.pboard

See http://apple.stackexchange.com/questions/31866/copy-and-cut-sometimes-dont-work

@alexandrudima

This doesn't work for me.

Actually I only have copy-paste issue in non-editor area, e.g. the search panel and the search prompt. Check the following gif, I can successfully paste the text from context menu, but not via keyboard shortcut, so I think it's not the issue of clipboard subsystem.

Bumping this - experiencing the same issue in v 1.16 on MacOS 10.12.6f from within tmux and ZSH Shell.

Same issue here.

Same issue right now!
MacOS 10.12.6

i got the same issue. cannot paste to visual studio code
macos 10.12.6

Updated to MacOS 10.13 (High Sierra) can confirm the issue persists. VS Code version 1.16.1.

Same issue here. VSCode 1.16.1 on MacOS 10.12.6. Using tmux type code to open the project then I couldn't use copy/paste shortcut key combination.

A workaround for now is to start vscode "outside" of tmux, then newly spawned windows using code inside tmux will have copy/paste.

I would enjoy if copy and paste would be working so I can remove the tmux configuration, since I have enabled the option in iTerm to integrate tmux. I am using

VSCode 1.17.1,
tmux 2.6 and
iTerm 3.1.3.

However, for all reading this you can fix it "correctly" with brew install reattach-to-user-namespace and the following tmux option set -g default-command "reattach-to-user-namespace -l $SHELL". Below you can find my tmux.conf:

## List of plugins managed by TPM.
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'

## Enable UTF-8.
set -g utf8 on
set -g status-utf8 on

## Start window numbering at 1
set -g base-index 1
set-window-option -g pane-base-index 1

## Enable mouse support.
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

## Enable focus events for terminals which supports them.
set -g focus-events on

## Address VIM mode switching delay (http://superuser.com/a/252717/65504).
set -s escape-time 0

## Required by MacOS Sierra and Sierra High.
set -g default-command "reattach-to-user-namespace -l $SHELL"

## Initialize TMUX plugin manager.
run '~/.tmux/plugins/tpm/tpm'

# The condition in the tmux-sensible plugin does not seem to be working...
# This line is required since updating to Sierra High.
set-window-option -g aggressive-resize off

@estrode do you still see this?

As I am experiencing this issue, is there anything I can do to help with fixing / reproducing this @bpasero ?

Open for help 👍 , no clue where to start though. @Tyriar ?

Jumping back in here, currently using VS Code 1.21.0 on 10.13.4 Beta (17E170C) and the issue no longer persists for me. I can copy and paste back and forth just fine. Using iTerm2 3.0.15 to start code from CLI.

@jldeen where are you getting the Beta version from? I downloaded Visual Studio Code Insiders edition and I still get the same issue.

I'm using Beta 10.13.4 macOS, but not VS Code. I believe you need to be part of the Developer's program with Apple to have access to the macOS Beta software, but other than that, I'm not using anything beta.

* Edit - Looks like you can register here for macOS Beta: https://beta.apple.com/sp/betaprogram/

I've updated to Visual Studio Code 1.21.0 and OSX 10.13.4 Beta (17E170c) and still experiencing this issue. Though, my iTerm2 is 3.1.5.

Just to note, this only happens when I execute code . while in a TMUX session. Running code . from an iTerm terminal session itself doesn't exhibit this issue.

@stanleykylee and did you follow the advice in https://github.com/Microsoft/vscode/issues/24112#issuecomment-336672556 to enable copy/paste?

@bpasero sorry, I hadn't. I just did not and yes, it works with that option enabled. Is this the accepted fix or is this considered a work around for now?

Yes that seems to be the fix.

Sounds good. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DovydasNavickas picture DovydasNavickas  ·  3Comments

vsccarl picture vsccarl  ·  3Comments

philipgiuliani picture philipgiuliani  ·  3Comments

chrisdias picture chrisdias  ·  3Comments

shanalikhan picture shanalikhan  ·  3Comments