sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
807 stars 39 forks source link

Multicursor copy-paste unexpected behavior when copying and pasting entire or multiple lines #5959

Open nugged opened 1 year ago

nugged commented 1 year ago

Description of the bug

On macOS (but also maybe everywhere?), when using multiple cursors to copy and paste entire lines, the pasted content is not as expected. Instead of pasting each line at the corresponding cursor position, all three (N) lines are pasted three (or N) times.

I suspect the newline character at the end of each line may be causing the issue, as copying and pasting multiple words (without newlines) works as expected.

Steps to reproduce

  1. Start ST in safe mode.
  2. Create a new file with three lines of content.
  3. Create three multi-cursors, one at the beginning of each line.
  4. Select each line by pressing Cmd+L.
  5. Copy the selected lines by pressing Cmd+C.
  6. Move the cursors to new positions.
  7. Paste the copied lines by pressing Cmd+V.

This is "becomes with bad results": image

But this works as expected (if there are no new lines in each of the three lines): image

Expected behavior

I expect lines to be three times pasted one by one as I just copied them into my multi-cursor clipboard:

image

Actual behavior

But it makes 3x3 pasting thinking it's single same text (and sometimes that is needed, right, but not this time):

image

Sublime Text build number

4149 (but this was the same behavior since ages)

Operating system & version

macOS, latest (13.3.1 (a))

(Linux) Desktop environment and/or window manager

nope

Additional information

No response

OpenGL context information

No response

jfcherng commented 1 year ago

The "line count" should match the "cursor count" when doing paste. In your example, 6 lines are copied, so it will "work" if there are 6 cursors while pasting. But basically, I will just assume it only works when no \n is copied.

https://github.com/sublimehq/sublime_text/issues/1435#issuecomment-251518567

nugged commented 1 year ago

Aha, so multi-cursor never supported multilines inside... and I should change my perception of this feature? I see.

Anyway ST 🥇 behaves much better with multi cursor than VSCode so I can at least copy-paste set of words and 3x3 or NxN works (it didn't work for me in VSCode with that)

But - 🤔 ... perfection somewhere ahead 😄

🤗 🙏 thanks.

BenjaminSchaaf commented 1 year ago

Multi-cursor doesn't know what you had selected when copying. When copying using multi-cursor each selection is put on its own line. When pasting if the number of cursors matches the number of lines then each line is matched to each cursor. ie. you could paste your first using 6 cursors.

This could actually be improved to have the expected behavior by supplying additional information to the system clipboard that only ST understands, so I'm going to classify this as an enhancement.

nugged commented 1 year ago

It's clear now.

It looks like a more complicated extension of features needed to keep a special format in the clipboard. Maybe one day.

Anyway, 🤟 🤟 🤟 - ST4 is the most app I spend my days in :), so – thank you!