-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] multi select yank only yank the last line #4662
Comments
Here's what I tried:
Resulting output:
...i.e. all lines were pasted correctly. Note that if you moved the cursor between yanking and pasting (for example, if you moved the cursor to the end of the buffer with |
I'm Sorry, I tried it again, yes, I think yank is ok in the internal, but it's not ok with my system clipboard, I use a custom shell script which copied from: https://github.com/mawww/config/blob/604ef1c1c2f4722505d3d29a4fc95e763a1fddbb/kakrc#L78-L101 Here is keys: # system clipboard handling
evaluate-commands %sh{
if [ -n "$SSH_TTY" ]; then
copy='printf "\033]52;;%s\033\\" $(base64 | tr -d "\n") > /dev/tty'
paste='printf "paste unsupported through ssh"'
backend="OSC 52"
else
case $(uname) in
Linux)
if [ -n "$WAYLAND_DISPLAY" ]; then
copy="wl-copy -p"; paste="wl-paste -p"; backend=Wayland
else
copy="xclip -i"; paste="xclip -o"; backend=X11
fi
;;
Darwin) copy="pbcopy"; paste="pbpaste"; backend=OSX ;;
esac
fi
printf "map global user -docstring 'paste (after) from clipboard' p '<a-!>%s<ret>'\n" "$paste"
printf "map global user -docstring 'paste (before) from clipboard' P '!%s<ret>'\n" "$paste"
printf "map global user -docstring 'yank to primary' y '<a-|>%s<ret>:echo -markup %%{{Information}copied selection to %s primary}<ret>'\n" "$copy" "$backend"
printf "map global user -docstring 'yank to clipboard' Y '<a-|>%s<ret>:echo -markup %%{{Information}copied selection to %s clipboard}<ret>'\n" "$copy -selection clipboard" "$backend"
printf "map global user -docstring 'replace from clipboard' R '|%s<ret>'\n" "$paste"
} It seems that the shell script has some problems. Do you know how to deal with this? |
Generally the system clipboard can only hold a single chunk of text at a time, not a list of chunks. When you have multiple selections in Kakoune and try to yank them all to the system clipboard, it processes each selection one-at-a-time, with the result that each selection replaces the previous contents of the clipboard. When you go to paste, the only thing on the clipboard is the contents of the last-yanked selection. Most system clipboards these days support some kind of format negotiation, where an application can publish different kinds of data simultaneously, like a URL and HTML formatted text and plain text. Using this mechanism it would be possible for Kakoune to yank a "list of chunks of text" to the clipboard. However, I don't believe any of the tools mentioned in your config fragment (OSC 52, |
Thanks for your explanation! I learned a lot. I want to do this operation because I'm trying to learn Kakoune from Lines 93 to 108 in f3cb2e4
|
You can select the entire paragraph with Shift and the arrow keys, just like in VS Code, and you'll get something like this: That's one selection, which you can copy/paste to Kakoune's internal clipboard, or to the system clipboard, or whatever, and it should work as you expect. You can also select the entire paragraph by pressing Kakoune detects a paragraph as "one or more non-blank lines, surrounded by blank lines". To a human, that selection looks like two paragraphs, but because the ASCII-art key diagram on the left straddles the paragraph break, there is no line that is fully blank, so Kakoune does not see a paragraph break there. However, you probably just want to select the text "column" and not include the ASCII-art on the left. As you've figured out, the way to do this is to use Because that's 16 selections rather than 1, it can't be (usefully) yanked to the system clipboard in the same way VS Code would do it, for the reasons discussed above. It's also a bit awkward to work with in Kakoune, since the selection doesn't include the line-break at the end of the line, so yanking this selection and pasting it elsewhere will produce a bunch of text all on the same line. We can extend each selection to include the trailing line-break by pressing Now we can press Now we have the text isolated without the ASCII-art interleaved, we can select the entire paragraph with a single selection (Shift+arrows, or Adding more natural system clipboard to Kakoune would be a good thing (#3935) but it's not obvious how to cleanly integrate such a feature with the way Kakoune works. |
Thanks, I tried your workflow, and it works fine. This is not a very frequent operation, so it is acceptable. |
I found that my |
I also tried with helix and I think helix has the expected operation for this. maybe they convert multiple selections? https://github.com/helix-editor/helix/blob/master/helix-view/src/clipboard.rs |
Why do you say they're broken? What happens when you try to use them?
The clipboard API you link to puts a single string on the clipboard and takes a single string from the clipboard. If Helix is squashing its internal representation to a single string to interact with a clipboard, it's happening somewhere else. You could probably do the same thing with your clipboard plugin by automating the "paste to a new scratch buffer then re-yank" trick I described above. |
Version of Kakoune
346b81b
Reproducer
CCCCC
, thenL
select to end, 5 lines are selected, theny
, yanked, thenp
, only last line is pasted.Outcome
only last line is yanked
Expectations
all selected lines should be yanked.
Additional information
No response
The text was updated successfully, but these errors were encountered: