Author Topic: Selection / function diff.  (Read 4847 times)

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Selection / function diff.
« on: July 04, 2009, 07:36:34 PM »
Selection diff.

Have to say that I don't often do file diffs (usually they're done before I get to editing). What I do do quite a lot is try to figure out what's different between two seemingly identical functions.

ch

  • Community Member
  • Posts: 13
  • Hero Points: -1
Re: Selection / function diff.
« Reply #1 on: July 07, 2009, 01:12:22 PM »
Selection diff.

...figure out what's different between two seemingly identical functions.

This.

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Re: Selection / function diff.
« Reply #2 on: February 22, 2015, 08:18:26 PM »
Need a quick way to compare 2 selections in a file.  I know that you can manually enter in the line number range in DiffZilla but that gets painful real quick.

(There seems to be a diff-cua-select2 command which sounded promising but it doesn't show up in the documentation and didn't seem to diff my selections).

JimmieC

  • Senior Community Member
  • Posts: 490
  • Hero Points: 17
Re: Selection / function diff.
« Reply #3 on: February 23, 2015, 02:50:29 PM »
Need a quick way to compare 2 selections in a file.  I know that you can manually enter in the line number range in DiffZilla but that gets painful real quick.

Just had to work 10 hours last Saturday for multiple project reasons, primarily schedule of course.
But, the issue I was working on could have used that feature exactly. Instead I split the window and had to compare it myself visually.

On other cases where I needed to this, I had to copy the section into a temp file so that I could compare it.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Selection / function diff.
« Reply #4 on: February 25, 2015, 02:49:16 AM »
Need a quick way to compare 2 selections in a file.  I know that you can manually enter in the line number range in DiffZilla but that gets painful real quick.

(There seems to be a diff-cua-select2 command which sounded promising but it doesn't show up in the documentation and didn't seem to diff my selections).

I wrote some code for this.  Could you try it out please?  I've tested in V19 only but it probably works in older versions.

It doesn't work with two concurrent selections - that's too much work.  Instead you select the first region then run the command xset_diff_region,  then select a second range of lines and run xcompare_diff_region. 

If you run xset_diff_region without a selection it starts with the current line and goes for 200 lines.  If you run xcompare_diff_region without a selection it starts with the current line and compares an extra 50 lines above the length of the first region to try and allow for the second region having expanded.

"x" means external macro so not to clash with installation macros.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2897
  • Hero Points: 153
Re: Selection / function diff.
« Reply #5 on: February 12, 2016, 05:18:54 PM »
I have seen where Beyond Compare can work around some of the line/source diffing that diffzilla doesn't easily handle.

For example.  If I take a function within a file and move it to the end of the file and then make one line change (e.g., add a character) within that moved function.

With Beyond Compare, you can open the old file and the new file, tell it to realign a starting block (F7) with a different location in the other file (click where to start realignment) so that the two (old/new) locations of the function line up and then I can see my single change of the function, even though it moved several lines/functions away from its original location.   I have yet to figure out how to make these realignments on the fly within diffzilla.

When diff'ing XML (particularly XML that applications reorder all the time), this is very useful.

We'll be adding this feature for SlickEdit 2016 (v21).  Thanks for the idea and please keep the ideas coming.

Did you try the function diff at all?  I know it won't help for XML, but normally it is just the ticket for the situation you described.

b

  • Senior Community Member
  • Posts: 325
  • Hero Points: 26
Re: Selection / function diff.
« Reply #6 on: February 12, 2016, 06:15:42 PM »
I did try that, but my diffs tend to be those against the repository, not a second file (other than the temporary file created by SE to pass to diffzilla).   Thus, I go to Tools -> Version Control -> Diff...., this doesn't ever provide a dialogue to configure lines, but goes straight to diffzilla.

I just tried taking a file I'm working on, purposefully moving a method from one location of the file to another and then arbitrarily removing a line of code.   Saved and then tried Tools -> Version Control -> Find symbol changes in <file>... Selected the method I moved and afterwards it stated there were no changes (yet I removed a line of code, so there was a change).   Where Tools -> Version Control -> Diff <file> with most up to date version showed the block addition and block removal).   

As stated before, the pull downs in the latter SE launched diffzilla don't seem to do anything other than relocate placement in the corresponding file/buffer (Select the method in the first window places the cursor to the method with second window showing the deletion block, but set the pull down in the second window and it just relocates the cursor to the method in the second window, shift the first window with it  to its deletion block).

I look forward to the new feature, which hopefully handles this use case.  Or, some how when SE launches diffzilla indirectly via version control, it provides the missing dialogue box so that you can check the specific lines, et al.

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Selection / function diff.
« Reply #7 on: February 12, 2016, 06:20:44 PM »
@b, if you want to see a diff of the file you changed, try using File->Backup history for.

b

  • Senior Community Member
  • Posts: 325
  • Hero Points: 26
Re: Selection / function diff.
« Reply #8 on: February 12, 2016, 06:50:32 PM »
@Tim Kemp,   I do use that very frequently, but that, too, doesn't address the issue of when a function/method moves in the file and you want to diff the changes of the method.  It only shows that you moved a block, but you can't diff the changes of the moved block (function/method).

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Selection / function diff.
« Reply #9 on: February 12, 2016, 06:57:25 PM »
That's true. I missed what you were trying to accomplish.


Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2897
  • Hero Points: 153
Re: Selection / function diff.
« Reply #10 on: February 12, 2016, 07:04:02 PM »
I did try that, but my diffs tend to be those against the repository, not a second file (other than the temporary file created by SE to pass to diffzilla).   Thus, I go to Tools -> Version Control -> Diff...., this doesn't ever provide a dialogue to configure lines, but goes straight to diffzilla.

I just tried taking a file I'm working on, purposefully moving a method from one location of the file to another and then arbitrarily removing a line of code.   Saved and then tried Tools -> Version Control -> Find symbol changes in <file>... Selected the method I moved and afterwards it stated there were no changes (yet I removed a line of code, so there was a change).   Where Tools -> Version Control -> Diff <file> with most up to date version showed the block addition and block removal).   

As stated before, the pull downs in the latter SE launched diffzilla don't seem to do anything other than relocate placement in the corresponding file/buffer (Select the method in the first window places the cursor to the method with second window showing the deletion block, but set the pull down in the second window and it just relocates the cursor to the method in the second window, shift the first window with it  to its deletion block).

I look forward to the new feature, which hopefully handles this use case.  Or, some how when SE launches diffzilla indirectly via version control, it provides the missing dialogue box so that you can check the specific lines, et al.

Tools -> Version Control -> Find symbol changes in <file>... only works on checked in versions, so if you hadn't checked the file it, it wouldn't show up there.

What would probably be more useful is for a given file go to Tools>Version Control>History for <file> and at the bottom of the dialog click on "See List of Changed Symbols". This will list the changes that occurred between the currently selected version and previous version.  They will show up as hotlinks so you can click on a function in the list and it will diff just the functions. 

Let me know if you have any trouble with this (if you have time to try it).

b

  • Senior Community Member
  • Posts: 325
  • Hero Points: 26
Re: Selection / function diff.
« Reply #11 on: February 12, 2016, 07:34:06 PM »
I'm confused, are you saying that Tools->Version Control->Find symbol changes in <file>... only will look at the last commit and the previous commit of a file?  I would have expected it to look at the last commit and the current sandbox of the file similar to Tools->Version Control->Diff <file> with most up to date version.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2897
  • Hero Points: 153
Re: Selection / function diff.
« Reply #12 on: February 12, 2016, 07:35:32 PM »
Right, it only does checked in versions.  I suppose I could make it treat the local version as the most recent version.  I simply didn't think of it that way because when I use that feature I'm generally looking for something in the past.

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Re: Selection / function diff.
« Reply #13 on: February 12, 2016, 08:40:36 PM »
Often just aligning the first line of a change still isn't enough of a hint to the tool when the changes are substantial ... and/or when other code in the vicinity is similar to the code being compared ...

So the Beyond Compare align feature also allows you to force the compare to a specified section
  • select a selection of text in one file
  • select the align command
  • select a section of text in the second file to compare against

This can dramatically improve the compare tool's ability to compare/contrast the actual lines you care about.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2897
  • Hero Points: 153
Re: Selection / function diff.
« Reply #14 on: February 15, 2016, 04:34:22 PM »
I'm confused, are you saying that Tools->Version Control->Find symbol changes in <file>... only will look at the last commit and the previous commit of a file?  I would have expected it to look at the last commit and the current sandbox of the file similar to Tools->Version Control->Diff <file> with most up to date version.

I gave this some thought over the weekend and I'm going to change the way this works to include the local file.