Bug 211254

Summary: Change behaviour when pasting and having something block-selected
Product: [Applications] kate Reporter: Marco Poletti <poletti.marco>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: CLOSED DUPLICATE    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

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 ***