Bug 211254 - Change behaviour when pasting and having something block-selected
Summary: Change behaviour when pasting and having something block-selected
Status: CLOSED DUPLICATE of bug 211251
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-20 21:49 UTC by Marco Poletti
Modified: 2009-11-05 10:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Poletti 2009-10-20 21:49:07 UTC
Version:            (using KDE 4.3.1)
OS:                Linux
Installed from:    SuSE RPMs

Type the following in Kate:

foo(0,1,2);
foo(0,1,2);
foo(0,1,2);

Then switch to block-selection mode, select the 2s, press Ctrl+C, select the 3s and press Ctrl+V.

Current result:

foo(1,2,);
foo(1,2,);
foo(1,2,2);
        2
        2

Expected result:

foo(1,2,2);
foo(1,2,2);
foo(1,2,2);

Explanation:

When you paste in block selection mode, you actually do 3 things:

1) Move cursor to end of selected text
2) Delete selected text
3) Paste

This is not useful IMHO.
I'd rather do something like this:

------CODE-------
n = heightOfCurrentSelection();
m = heightOfPastedSelection();

if (m!=0)
    for (int i=0; i<n; i++) {
        
        int k = (i % m);
        
        ... // Replace the i-th row of the selection
        ... // with the k-th row of the pasted text
    }

clearSelection();
------END-CODE-------

If n==m, you get what you expect (however, not current behavior).
With the mod, you even get interesting results when n!=m.
If n<m, the additional rows pasted are ignored (not sure what should we do in this case).

If n>m, the pasted rows are repeated to fill the selected rows. So if you have this:

foo(1,1);
foo(1,2);
foo(1,3);

and have «,2)» selected, you can add the argument «2» to all calls by selecting the «)» column and pasting.
Comment 1 Marco Poletti 2009-10-20 22:00:38 UTC
Sorry, double report.

*** This bug has been marked as a duplicate of bug 211251 ***