Author Topic: Multiple cursors, copy-n-paste is unreliable.  (Read 3991 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Multiple cursors, copy-n-paste is unreliable.
« on: September 20, 2016, 10:42:54 PM »
I've seen this before RC2 as well, but I'm complaining about it now...

In Tbfilelist.e, goto line 25, colum 10
   #import "files.e"
   #import "fileman.e"
   #import "guiopen.e"
   #import "listproc.e"
   #import "main.e"
   #import "project.e"
   #import "projutil.e"

select_block();
cursor down 5 times (6 lines selected).
add-multiple-cursors
Ctrl+Shift+Right 2 or 3 times (or ctrl+Shift+End)
HOME
Paste

Expected:
   files.e"#import "files.e"
   fileman.e"#import "fileman.e"
   guiopen.e"#import "guiopen.e"
   listproc.e"#import "listproc.e"
   main.e"#import "main.e"
   project.e"#import "project.e"
   projutil.e"#import "projutil.e"


But, sometimes I get the following.

I thought I had a solid repro, then slick crashed.
After restart it was much harder to repro, but I did.
After a failed-repro attempt, then while I had multiple cursors I played around with Home, End, Undo, Redo, Paste, etc.
Then, sometimes it will repro.

Note also that I have seen other bad-behavior combining Undo with Multiple cursors, but no solid repro steps.
For example, I did something like the above, but I pasted multiple times, hit End, hit Undo a few times.
Undo didn't undo all of my changes -- it left several of the paste operations in place (the buffer was still in the modified state).


   #import "complete.e"
   #import "context.e"
   #import "diff.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "files.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "fileman.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "guiopen.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "listproc.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "main.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "project.e"
   files.e"
   fileman.e"
   guiopen.e"
   listproc.e"
   main.e"
   project.e"
   projutil.e"#import "projutil.e"
   #import "sellist.e"
   #import "stdprocs.e"

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #1 on: September 21, 2016, 12:20:12 AM »
I just managed to reproduce this. Not sure how fixable this is. It's like the system clipboard gets corrupted (not SlickEdit's internal clipboards). The OleSetClipboard() call is failing. Qt does not return an error status when this happens. However, I always run a debug version of SlickEdit.  In debug mode, the Qt libraries display an error when this happens and I can always see it. I never reboot my machine and I wonder if that has something to do with it.

This problem most likely has nothing to do with undo/redo etc.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #2 on: September 21, 2016, 01:04:58 AM »
Interesting ....
Using ClipX http://bluemars.org/clipx/ - which shows clipboard history.

When I do that multi-cursor copy, ClipX shows (note: The most recent clip is on top
    files fileman guiopen listproc main project
    files fileman guiopen listproc main
    files fileman guiopen listproc
*3* clips are created.

In a failure case where we get bad pasting, ClipX shows *5* copy operations
    files fileman guiopen listproc main
    files fileman guiopen listproc
    files fileman guiopen
    files fileman
    files

Notice also that the first time "project" is included, but in the 2nd case it isn't - yet I did select and copy it both times...

Why is it doing such odd clipboard operations?

Maybe the failure is due to the rapid-fire copies - and sometimes its a little slow??

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #3 on: September 21, 2016, 03:01:33 AM »
I think I've figured out a way to fix this...Let's hope

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #4 on: September 21, 2016, 03:16:15 AM »
Are you running under Windows 10 or Windows 7?

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #5 on: September 21, 2016, 04:33:29 AM »
7 on that machine, but 10 on another.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #6 on: September 21, 2016, 06:24:27 PM »
Fixed for RC 3. The problem is that other processes (outside SlickEdit), must be opening and closing the clipboard when they are not active. Only one process can open the clipboard at a time. The fix was to simply retry a bit.

I can still reproduce this problem but only with a very badly behaved windows program that I wrote. It keeps the clipboard open for a very long time.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #7 on: September 21, 2016, 06:39:21 PM »
With multiple cursor copy, why does slick do "N" copies to the clipboard? (Where "N" is the number of cursors).

Since Slick uses its internal clipboard, why does a system clipboard failure affect it?

A tool like ClipX certainly monitors the clipboard, but I wouldn't expect many other apps to need to.

Hah! Excel does. (Its a little weird, but other apps may do things you don't expect too).
Open excel, select a few cells, copy.
It keeps the copied cells highlighted.
Switch to another app - keeping Excel visible.
Copy - as soon as the other app does the Copy, the highlight in Excel disappears.




Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #8 on: September 21, 2016, 08:42:28 PM »
I think SlickEdit only needs to copy the final result to the clipboard. It's a missed optimization. I'll see if we can change this.

In order for SlickEdit to know it has an internal clipboard, it puts some internal record keeping data on the clipboard as well as a copy of the clipboard data for other apps to use.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Multiple cursors, copy-n-paste is unreliable.
« Reply #9 on: September 21, 2016, 09:37:47 PM »
Looks like the code was trying to only the final result to the clipboard but the optimization has a bug. This is fixed for RC 3