Copyq: "Paste to current window" isn't working in IntelliJ IDEA

Created on 29 Oct 2016  路  16Comments  路  Source: hluk/CopyQ

In configuration window (preferences) in history tab I have all checkboxes checked. This auto-paste feature is working in Atom and Kate flawlessly, but for some reason not in IDEA. Just to be sure I removed conflicting shortcut from IDEA, behavior is the same - CopyQ moves selected snippet to clipboard, but fails to paste it into IDEA (cursor in IDEA breaks, window switch fixes it).

CopyQ 2.7.1
IntelliJ IDEA 2016.2.5 (Ultimate, but I guess it is broken in Community edition as well)
Kubuntu 16.04

packages:

# dpkg -l | ack 'xfixes|libxtst|qt.?webkit|qt.?core'
ii  libqt5core5a:amd64                                          5.5.1+dfsg-16ubuntu7.2                        amd64        Qt 5 core module
ii  libqt5webkit5:amd64                                         5.5.1+dfsg-2ubuntu1                           amd64        Web content engine library for Qt
ii  libqtcore4:amd64                                            4:4.8.7+dfsg-5ubuntu2                         amd64        Qt 4 core module
ii  libqtcore4:i386                                             4:4.8.7+dfsg-5ubuntu2                         i386         Qt 4 core module
ii  libqtwebkit4:amd64                                          2.3.2-0ubuntu11                               amd64        Web content engine library for Qt
ii  libqtwebkit4:i386                                           2.3.2-0ubuntu11                               i386         Web content engine library for Qt
ii  libxcb-xfixes0:amd64                                        1.11.1-1ubuntu1                               amd64        X C Binding, xfixes extension
ii  libxcb-xfixes0:i386                                         1.11.1-1ubuntu1                               i386         X C Binding, xfixes extension
ii  libxcb-xfixes0-dev:amd64                                    1.11.1-1ubuntu1                               amd64        X C Binding, xfixes extension, development files
ii  libxfixes-dev:amd64                                         1:5.0.1-2                                     amd64        X11 miscellaneous 'fixes' extension library (development headers)
ii  libxfixes3:amd64                                            1:5.0.1-2                                     amd64        X11 miscellaneous 'fixes' extension library
ii  libxfixes3:i386                                             1:5.0.1-2                                     i386         X11 miscellaneous 'fixes' extension library
ii  libxtst6:amd64                                              2:1.2.2-1                                     amd64        X11 Testing -- Record extension library
ii  qml-module-qtwebkit:amd64                                   5.5.1+dfsg-2ubuntu1                           amd64        Qt WebKit QML module
ii  qtcore4-l10n                                                4:4.8.7+dfsg-5ubuntu2                         all          Qt 4 core module translations

Most helpful comment

Oh, it seem I can reproduce it but only sometimes. Some interval after closing CopyQ could help, e.g.

[Command]
Command="
    copyq:
    hide()
    execute('sleep', '0.1')

    var text = input()
    copy(text)
    copySelection(text)
    paste()"
Icon=\xf0ea
InMenu=true
Input=text/plain
Name=Paste as Plain Text
Shortcut=enter

It may even work if you pass smaller interval to "sleep" -- it's not very snappy with "0.1" -- or remove it completely.

All 16 comments

Works for me in IntelliJ IDEA 2016.2.5 Community on Arch Linux.

Perhaps window manager or a plugin break the behavior. Does pasting in the IDE work using Shift+Insert?

Alternatively you can try overriding default behavior using following command (copy/paste the code below to Command list in Command dialog F6; it requires xdotool utility).

[Command]
Command="
    copyq:
    var text = input()
    copy(text)
    copySelection(text)
    execute('xdotool', 'key', 'shift+Insert')"
HideWindow=true
Icon=\xf0ea
InMenu=true
Input=text/plain
Name=Paste Selected Items
Shortcut=enter

No, shift+insert is not working, it is assigned to some plugin. Is there a way to set CopyQ to use ctrl+v?

I have tried (after installing xdotool):

[Command]
Name=Paste Selected Items
Command="
    copyq:
    var text = input()
    copy(text)
    copySelection(text)
    execute('xdotool', 'key', 'ctrl+V')"
Input=text/plain
InMenu=true
HideWindow=true
Icon=\xf0ea
Shortcut=enter

but it isn't working as intended. After selecting an item by enter clipboard is not pasted and CopyQ window is reopened.

Put following line in ~/.config/copyq/copyq.conf configuration file and CopyQ will use Ctrl+V to paste item to the IDE.

[General]
paste_with_ctrl_v_windows="- IntelliJ IDEA"

You should disable the automatic command for this to work.

Hmm, maybe the above commands doesn't work because there should be hide() function call to hide the CopyQ window prior to paste().

Thank you, pasting now works. Unfortunately it almost always leads to the cursor break - quite annoying after every paste having to switch to other window and back :(. Not sure if it is an issue with IDEA or CopyQ.

Did you try pasting from tray menu? (You can add "Show the tray menu" command and assign shortcut to show the menu.) Window managers treat menu focus very differently so maybe this could work fine.

You are right, pasting from tray menu works. But I couldn't find search functionality or it isn't available in tray menu?

It's interesting, it probably works from tray menu because IDEA behaves as it is having focus (blinking cursor).

It's currently not possible to search in tray menu - there is old feature request for this (#145).

Oh, that's unfortunate. I have recently migrated to Linux from Windows where I was using mentioned Ditto. I really miss the filtering option :cry:. It allowed very quick flow - _ctrl+shift+v, few letters from older clip, enter_. For comparison - CopyQ with filtering in IDEA: _ctrl+shift+v, few letters from older clip, enter, alt+tab, alt+tab_ (to fix broken cursor). That's almost two times more shortcuts required. Or use it without filtering, but then there is not much benefit compared to built-in clipboard manager in IDEA.

CopyQ has some more advanced features, but this IMO simpler one would be very handy.

Thank you for your answers and your time.

PS: Not sure if I should close this issue, since pasting from main window to IDEA is broken (the focus loss). But it might be more clear to create a new issue with description of that one problem, after all this issue is more a support one.

Keep this issue open. I'll try to test this with KWin window manager (I suppose that's the window manager you use on Kubuntu).

Ok.

Yes, I am using KWin.

Also it seems the bug isn't only about focus loss, because sometimes characters I type are rendered in IDEA (without cursor being shown), other times some IDEA dialog pops-up (I think it's "recent files", but I am not sure, I don't know how to force repeating of this behavior). So there might be other problems, maybe ctrl/shift being still detected as pressed by IDEA or something similar.

Even with KWin 5.8.2 pasting and focusing seems to work. Perhaps it's some configuration in KWin or a plugin in IDEA that messes focusing.

Another interesting thing is that Shift+Insert is not assigned to "Edit | Paste" in IDEA in your configuration. Did you reassign the shortcut?

I don't think I reassigned it, probably some plugin did. I assigned it back to paste and removed ctrl+v line from CopyQ config, but with shift+insert it behaves exactly same as with ctrl+v.

Version of KWin in Kubuntu is a bit older - kwin -v reports 5.5.5.

Here's a short video to illustrate the issue - https://www.youtube.com/watch?v=QwqF9L-msQ0 (enable subtitles to see comments).

Oh, it seem I can reproduce it but only sometimes. Some interval after closing CopyQ could help, e.g.

[Command]
Command="
    copyq:
    hide()
    execute('sleep', '0.1')

    var text = input()
    copy(text)
    copySelection(text)
    paste()"
Icon=\xf0ea
InMenu=true
Input=text/plain
Name=Paste as Plain Text
Shortcut=enter

It may even work if you pass smaller interval to "sleep" -- it's not very snappy with "0.1" -- or remove it completely.

Great, good job! It works even without sleep. It's not lightning fast, but I think it is perfectly usable ^_^.

Thank you very much.

Great. I think you could remove copySelection() and get some speed out of it but it may not work with some terminals.

Was this page helpful?
5 / 5 - 1 ratings

Related issues

bsucker98 picture bsucker98  路  4Comments

nmat picture nmat  路  6Comments

Gitoffthelawn picture Gitoffthelawn  路  8Comments

gflex picture gflex  路  5Comments

SmileyStiles picture SmileyStiles  路  3Comments