Bug 401400 - kate vi mode does not synchronize content from clipboard
Summary: kate vi mode does not synchronize content from clipboard
Status: RESOLVED WORKSFORME
Alias: None
Product: kate
Classification: Applications
Component: Vi Input Mode (show other bugs)
Version: 18.08.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-25 15:14 UTC by Ritesh Raj Sarraf
Modified: 2023-12-18 19:37 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kate clipboard (139.80 KB, image/png)
2019-05-15 15:45 UTC, Ritesh Raj Sarraf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ritesh Raj Sarraf 2018-11-25 15:14:48 UTC
SUMMARY
kate vi mode does not synchronize content from clipboard

STEPS TO REPRODUCE
1. Open kate.
2. write some text in vi mode and then also copy it
3. quite kate
4. Open a web browser and open some page
5. select and copy some text to klipper clipboard
6. Open kate again. (in vi mode)
7. Do a vi-mode paste.
8. You should have pasted the buffer from the clipboard.
9. But what was pasted to kate ?

OBSERVED RESULT
Stale buffer from old kate session loaded and pasted

EXPECTED RESULT
Buffer from clipboard should be pasted

SOFTWARE/OS VERSIONS
KDE Plasma: 5.13.5
KDE Framework: 5.49.0
Qt: 5.11.2
Linux, Debian
Comment 1 Ahmad Samir 2019-03-23 15:40:06 UTC
Can you still reproduce this issue?
Comment 2 Ritesh Raj Sarraf 2019-03-26 07:28:32 UTC
(In reply to Ahmad Samir from comment #1)
> Can you still reproduce this issue?

Yes. Very very reproducible. Are you not able to reproduce it with the steps I have outlined ?
Comment 3 Ahmad Samir 2019-03-26 11:33:11 UTC
I couldn't reproduce this issue. You're using klipper from the system tray widget (Configure system tray ->  Clipboard).

Also by "vi-mode paste" you mean just using Ctrl+v, right?
Comment 4 Ritesh Raj Sarraf 2019-03-27 04:20:30 UTC
(In reply to Ahmad Samir from comment #3)
> I couldn't reproduce this issue. You're using klipper from the system tray
> widget (Configure system tray ->  Clipboard).
> 

Yes, I'm using klipper. I'm surprised that you are not able to reproduce the issue.

 
> Also by "vi-mode paste" you mean just using Ctrl+v, right?

NO. "vi-mode paste" would mean you paste using the 'p' key for whatever is in the buffer.
Comment 5 Ritesh Raj Sarraf 2019-03-27 04:21:54 UTC
(In reply to Ritesh Raj Sarraf from comment #4)
> (In reply to Ahmad Samir from comment #3)
> > Also by "vi-mode paste" you mean just using Ctrl+v, right?
> 
> NO. "vi-mode paste" would mean you paste using the 'p' key for whatever is
> in the buffer.

Using the 'p' key in "vi-mode's" 'command mode'.
Comment 6 Ritesh Raj Sarraf 2019-03-27 05:17:16 UTC
In this video, I have tried to explain the bug.
https://www.youtube.com/watch?v=sUG4FaPoStk
Comment 7 Ahmad Samir 2019-05-14 19:46:57 UTC
In vi-mode, kate behaves like this, IIUC:
- if you copy text via Ctrl+C or yanking (which is specific to vi-mode), you can paste the text with Ctrl+V (in and out of kate) or a plain command p
- if you copy text from outside kate, you can paste it in kate via Ctrl+v, but if you want to paste it via the vi-mode commands you'd have to use "+p

So, if there's a bug here, I'd say that kate shouldn't copy the text to the clipboard if the user yanks the text in vi-mode, that would match the behaviour in vim. But I am by no means an expert when it comes to vim or the vi-mode in kate, so...
Comment 8 Ritesh Raj Sarraf 2019-05-15 15:25:08 UTC
(In reply to Ahmad Samir from comment #7)
> In vi-mode, kate behaves like this, IIUC:
> - if you copy text via Ctrl+C or yanking (which is specific to vi-mode), you
> can paste the text with Ctrl+V (in and out of kate) or a plain command p
> - if you copy text from outside kate, you can paste it in kate via Ctrl+v,
> but if you want to paste it via the vi-mode commands you'd have to use "+p
> 

Can you please elaborate a little about using "+p ?
If that is a special case and works, that still is a good thing.

> So, if there's a bug here, I'd say that kate shouldn't copy the text to the
> clipboard if the user yanks the text in vi-mode, that would match the
> behaviour in vim. But I am by no means an expert when it comes to vim or the
> vi-mode in kate, so...


I agree. But that is something for you or the other developers to confirm. Even in vim, there's the +clipboard feature wherein when you yank something in vim, it gets copied to the clipboard.

Now, like you said, it could very well be that kwrite/kate is internally having its own clipboard when run in 'vi mode'. And it copies the buffer to that clipboard when something is yanked in kate's 'vi mode'. Doesn't feel like that is what the kate devs must have done, but there is the possibility. And if that is the case, it'd be nice to have this bug report turned into a Feature Request to have an option to sync 'vi-mode' copy buffers to the Klipper clipboard. Essentially, implement the equivalent of vim's +clipboard feature.
Comment 9 Ritesh Raj Sarraf 2019-05-15 15:45:04 UTC
Created attachment 120084 [details]
kate clipboard

No need to confirm for any one. It does look like kate has its own clipboard for `vi-mode`
Comment 10 Ahmad Samir 2019-05-23 18:15:06 UTC
Technically what kate does is:
- if you yank text in vi-mode, you can put/paste in in kate via p command
- that same text is copied to the clipboard so you can paste it anywhere (in kate or in any other app) via Ctrl+V, this behaviour is specific to kate
- now say you copied some text to the clipboard in any other app, you have the two options:
 - paste that text in kate via Ctrl+V or in vi-mode using "+p
 - put/paste the text you yanked previously via the p command

I think you should have a look at: https://vimhelp.org/change.txt.html#copy-move
Comment 11 Prajna Sariputra 2021-11-02 03:12:20 UTC
> now say you copied some text to the clipboard in any other app, you have the two options:
>  - paste that text in kate via Ctrl+V or in vi-mode using "+p
>  - put/paste the text you yanked previously via the p command

So, since that appears to be the intended behaviour, would adding the option to make the p command use the system clipboard (or more generally have the internal/default clipboard be synced to the system one) be considered? Vim does support it via the `set clipboard=unnamedplus` command (not the +clipboard feature since that only enables system clipboard access).
Comment 12 Prajna Sariputra 2021-11-02 03:23:46 UTC
Actually, I just realised that there is a key mapping option specifically for the Vi input mode, so simply substituting p with "+p works. Assuming that doesn't break anything else (at least compared to Vim with `set clipboard=unnamedplus`), I guess this bug can be closed then?
Comment 13 Andreas 2022-03-11 10:06:38 UTC
In fact "<left>as" also behaves differently in kate and vim. Perhaps more with the "<left>" modification.
Comment 14 Andreas 2022-03-11 10:07:50 UTC
Sorry, my previous comment applies to another bug!
Comment 15 Christoph Cullmann 2023-12-18 19:37:09 UTC
I think the original bug was solved, if I don't misread the comments below.