helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.76k stars 2.51k forks source link

Cannot paste multi line text from system clipboard in some cases #8600

Closed CptPotato closed 1 year ago

CptPotato commented 1 year ago

Summary

I continue running into an issue where pasting multi-line text from the system clipboard (SpaceP) only inserts a single line.

I think I narrowed it down to my (ab)use of Spacey with multiple cursors to join and yank selections and then paste the combined text with SpaceP using a single cursor.

Reproduction Steps

Start with this file:

int main() {
    switch (1) {
        case 0: break;
        case 1: break;
        case 2: break;
        case 3: break;
    }
}

Expected result (this worked a while ago):

        case 0: break;

        case 1: break;

        case 2: break;

        case 3: break;

Actual result:

        case 0: break;

It almost seems like the clipboard's contents break somehow. If I paste the yanked text in another editor, I get the expected result and from there I can copy and (in helix) paste the text without issues.

I tried inspecting the bytes of the yanked text by saving the bad result as a file, but wasn't able to find anything.

Helix log

log (-vvv, nothing of interest) ``` 2023-10-24T13:04:35.912 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is not supported in this terminal (checked in 100ns) 2023-10-24T13:04:35.913 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:35.913 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:36.174 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:38.571 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:40.882 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:42.100 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:42.353 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:43.300 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0 2023-10-24T13:04:43.552 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:44.076 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:44.334 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:46.260 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:46.520 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:47.500 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:48.476 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:48.932 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:49.012 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:49.420 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:50.052 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:50.310 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:50.964 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:51.036 helix_view::editor [DEBUG] editor status: yanked 4 selections to register * 2023-10-24T13:04:51.036 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:51.295 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:52.380 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:52.640 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:53.036 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 1 2023-10-24T13:04:53.296 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:53.388 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 2 2023-10-24T13:04:53.641 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:54.996 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 2 2023-10-24T13:04:55.250 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:56.036 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 2 2023-10-24T13:04:56.284 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 2 2023-10-24T13:04:56.299 helix_term::application [DEBUG] received editor event: IdleTimer 2023-10-24T13:04:56.340 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 2 ```

Platform

Windows

Terminal Emulator

wezterm (nightly)

Helix Version

e6d2835b0907102831a8979688a8464c064ff842

pascalkuthe commented 1 year ago

this is expected behavior if you paste from helix to helix.

With #6985 helix now treats the clipboard the same as any other register with regards to multicursors.

Specifically y does not join selections anymore. So you would need to join selections first or use :yank-joined.

In the past running (for youx example) %s\d<ret><space>y<space>p would have pasted 1\n0\n1\n2\n3 at every cursor where now it will simply duplicate the number just as if you used y and p