Bug 497863 - Paste from clipboard to multiple cursors
Summary: Paste from clipboard to multiple cursors
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (other bugs)
Version First Reported In: 24.08.3
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-24 13:58 UTC by nomot16750
Modified: 2024-12-27 12:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.10
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nomot16750 2024-12-24 13:58:51 UTC
SUMMARY

When pasting to multiple cursors Kate should check if number of lines in the clipboard is the same as number of multiple cursors and split those lines to corresponding cursor, i.e. each cursor should get single line from the clipboard.

With current implementation in Kate every cursor gets all the lines from the clipboard.

This is example of similar implementation in Visual Studio Code:
https://github.com/microsoft/vscode/blob/4fa5611d67dc84e105e9cd155a746f2d7813d9a0/src/vs/editor/common/cursor/cursorTypeEditOperations.ts#L676

STEPS TO REPRODUCE

If we have text like this:

```
a
b
c

1
2
3
```

In Sublime Text and Visual Studio Code it is possible to cut three lines with numbers to the clipboard, select lines with letters, do split to multiple lines, use Home to put cursor at line start, make paste and get this:

EXPECTED RESULT

```
1a
2b
3c
```

OBSERVED RESULT

In Kate 24.08.3 we get this:

```
1
2
3a
1
2
3b
1
2
3c
```

ADDITIONAL INFORMATION

Original report: https://bugs.kde.org/show_bug.cgi?id=497152
Related discussion: https://discuss.kde.org/t/multiline-paste-with-the-same-number-of-lines/26128/4
Comment 1 Bug Janitor Service 2024-12-24 15:38:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/768
Comment 2 Waqar Ahmed 2024-12-25 11:13:46 UTC
Git commit 7ab7eec2351275dbdfaf49cbac860e70023a5be7 by Waqar Ahmed.
Committed on 25/12/2024 at 11:07.
Pushed by waqar into branch 'master'.

Try to split clipboard text across multiple cursors when pasting

If the number of lines in clipboard text == number of cursors then
paste each line of clipboard text at a cursor position instead of
pasting all text at each cursor position.
FIXED-IN: 6.10

M  +12   -0    autotests/src/multicursortest.cpp
M  +1    -0    autotests/src/multicursortest.h
M  +11   -5    src/view/kateview.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/7ab7eec2351275dbdfaf49cbac860e70023a5be7
Comment 3 nomot16750 2024-12-27 08:55:50 UTC
Will that work if text in the clipboard contains Windows or Mac line endings?
Comment 4 Waqar Ahmed 2024-12-27 10:03:38 UTC
Someone needs to test that
Comment 5 nomot16750 2024-12-27 12:13:19 UTC
If split is done on `\n` I guess it will not work with `\r` (Mac) line endings, and with `\r\n` (Windows) line endings it will produce new line when pasting.