Author Topic: B2: Undo not working after diff modified file  (Read 3325 times)

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
B2: Undo not working after diff modified file
« on: September 05, 2017, 05:45:42 PM »
To reproduce:

1) Open an existing text file
2) type 1 letter anywhere, and don't save the file
3) The tab shows the file is modified, right click the tab and do "diff" to see what you modified
4) Close the diff
5) Now type "Ctrl-Z" to undo the change that was made earlier, it can't be undone

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2896
  • Hero Points: 153
Re: B2: Undo not working after diff modified file
« Reply #1 on: September 05, 2017, 05:49:32 PM »
This has always been this way.  The reason is so you can't undo Imaginary Buffer Lines back into the buffer.  This will be changing in a future version.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: B2: Undo not working after diff modified file
« Reply #2 on: September 05, 2017, 06:29:03 PM »
Would the fix in a future version be a future version 22 or in a future year's product?

I don't quite understand what you mean by "can't undo Imaginary Buffer Lines back into the buffer."

What is an imaginary buffer line?

Sometimes I see that some of my tabs are modified when I didn't really expect it. I then use this "Diff" to see what changed, and often I find that I must have typed a key by accident into that buffer window. When this happens I want to undo the change, but I'm not able to due to this bug. because the undo history seems gone after diff. The only way to fix it is to close/reopen the file. Would prefer to use Undo.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2896
  • Hero Points: 153
Re: B2: Undo not working after diff modified file
« Reply #3 on: September 05, 2017, 06:35:35 PM »
When you diff two files, if there are inserted/deleted lines, a line is inserted that says "Imaginary Buffer Line".  These lines cannot be saved if you save the file, but they are actually in the buffer.  We have to clear the undo history because otherwise you could press undo and these lines would reappear.

We will address this in the future, but it will not be for v22.0.  It is not as simple of a fix as it sounds like.  It has actually been this way for over twenty years and doesn't come up that much.

When you find yourself in this case, you can probably use backup history.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: B2: Undo not working after diff modified file
« Reply #4 on: September 05, 2017, 06:44:32 PM »
In my case there are no inserted/deleted lines - usually when I want to do this is because I typed a key by accident, modified the file by accident and just want to undo it.

So maybe if there are no inserted/deleted lines then you can keep the undo history?

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2896
  • Hero Points: 153
Re: B2: Undo not working after diff modified file
« Reply #5 on: September 05, 2017, 06:52:59 PM »
I'm afraid not.  Because since you can edit in the diff output window, if you insert lines on one side, Imaginary Buffer Lines will be added to the other side.  Same if you delete lines on one side or another.  This would be difficult to track.

The right way to do this is to copy the buffer, diff that, and then overlay the results of that on top of the actual buffer. So that you can undo the everything that happened in the diff as one undo step.  It sounds very straight forward.  However, DIFFzilla has a lot of capabilities beyond "normal use" that affect this (diffing line ranges, diffing specific functions, source diff, etc) it complicates things.  Plus, as I said, the diff has been in the editor for twenty-one years.  So to do it right, some things should/would be cleaned up at the same time.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: B2: Undo not working after diff modified file
« Reply #6 on: September 05, 2017, 07:00:31 PM »
How about if the user does not edit the buffer while in Diff, and there are no inserted/deleted lines, then keep the undo history?

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2896
  • Hero Points: 153
Re: B2: Undo not working after diff modified file
« Reply #7 on: September 05, 2017, 07:13:57 PM »
Like I said, it would be tough to track.  Paste is allowed in the difference editor.  Cut is allowed.  So right off the top of my head that's two commands that might or might not affect whether or not the undo information needs to be cleared or not.  So at the very least, I need some time to look at it, and I can't commit to it for this version.

I would really rather fix this right instead of patching non-insert/delete cases.  I will try to be sure the priority of this gets bumped up for the next release.  There's a handful of diff issues that are a little bit like this that we would like to see resolved.  For instance, if you diff from version control, that dialog is modal.  I would like to change that too.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: B2: Undo not working after diff modified file
« Reply #8 on: September 07, 2017, 11:22:28 AM »
When you diff two files, if there are inserted/deleted lines, a line is inserted that says "Imaginary Buffer Line".  These lines cannot be saved if you save the file, but they are actually in the buffer.  We have to clear the undo history because otherwise you could press undo and these lines would reappear.

Maybe undo could recognize the non-saveable "imaginary buffer lines" and not actually add them back into the file when undo is used.


Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2896
  • Hero Points: 153
Re: B2: Undo not working after diff modified file
« Reply #9 on: September 07, 2017, 03:27:09 PM »
I think copying the buffer is probably a better solution, but we'll talk about that too.