#457 Dehighlight moved lines


Patch to detect moved lines, and not highlight them.

This isn't meant to be the final polished version so
much as a demonstration of the feasibility, because I'm
not sure about handling coloring.

This finds individual lines that moved, for clear
instances (that is, when one line on the left matches
only one line on the right, etc).

I returned moved lines arrays to the diff wrapper
(gives matching line numbers for moved lines), and
added a new line flags (LF_MOVED), and altered the
paint code to use ghost background for lines with
LF_DIFF and LF_MOVED, which deemphasizes them. I don't
have the detail paint code working properly.

It might be nicer to recognize entire moved blocks --
at the block level I mean -- also, when say 90% plus of
the left & right block match. I'm not sure if that is
feasible, but if so so, the whole block could then
optionally be removed from the difference list, which
would be nice (ie, the ability to screen out moved
differences from the difference list).


  • Anonymous - 2003-12-02

    Altered and original files (11 files) (145K)

  • Anonymous - 2003-12-02

    Logged In: YES

    This addresses RFE#[ 834500 ] Display (& compute) moved lines.

    Except, I didn't provide functionality to find the matching
    line on the other side visually, but the information is
    available internally. I'm just not sure where to store it
    (in the view ? in the textbuffer ? ) or how to give the user
    access to it (off a menu ?)

    (I didn't review that RFE before writing and submitting this

  • Anonymous - 2003-12-03

    Logged In: YES

    Demo versions of this (source & compiled) are available as
    experimental release (patch demo).

  • Kimmo Varis

    Kimmo Varis - 2003-12-11

    Logged In: YES

    If you can expand this to detect moved diffs... I don't know
    how we should show moved diffs though. Numbering diffs?
    Show text in statusbar "Selected diff in left side is
    similar to diff 8 in right side"? Somehow mark these moved
    diffs and then provide command "Find matching diff in
    left/right side"?

  • Anonymous - 2003-12-11

    Logged In: YES

    If you mean detect that the entire diff block is moved, that
    would be nifty, and I'd like that, but there is a technical

    Inside the diffutils, the hash arrays (which store all lines
    by hash, and which I used to find moved lines) are not kept
    very long, and are destroyed before diffutils computes the
    diffs. To find moved diff sections, I would need to modify
    diffutils to keep the hash arrays until later. This will
    obviously increase the changes we have in diffutils. I've
    not really taken a good look to see how much the change
    would be.

  • Anonymous - 2003-12-11

    Logged In: YES

    I have thought about the algorithm to use, however.

    I've thought of starting at the top line of the diff, and if
    the line has a unique match, go to next line. If not, check
    if a line adjacent to it has a unique match, and if so, does
    this line non-uniquely match up with the corresponding line
    on the other side. Proceed until a line doesn't match, or we
    hit the bottom of the diff. This algorithm will find moved
    but unchanged diffs I believe.

  • Anonymous - 2004-01-19

    Logged In: YES


    This is not in the 2.2 plan, but it does provide an
    alternate functionality to feature#7 (Show only different
    lines), which isn't likely to be provided in any other way
    any time soon.

  • Kimmo Varis

    Kimmo Varis - 2004-01-22

    Logged In: YES

    Whole WinMerge UI is based on idea of selectable diff
    blocks. Select and merge blocks. Not lines.

    That's why I think its consistent and more useful to detect
    and show moved diff blocks. If we find out nice UI for
    showing and merging moved blocks this will be very nice and
    useful feature.

    Instead of showing and giving user impression that one
    function is removed, we could show that function is actually

    At simplest, UI could be new color for moved diff and then
    UI items for showing (goto) destination diff in another
    pane, and merging moved diff.

  • Anonymous - 2004-01-22

    Logged In: YES

    Mm, you're right, UI is based on blocks. But of course
    diffutils is all based on lines (it has no concept of
    blocks). So, we build up blocks out of lines. That sounds
    good. Take a starting point of finding moved lines, then
    group them into contiguous blocks--those will be the moved

  • Anonymous - 2004-01-28

    Logged In: YES

    I believe there is a flaw in this patch, and I'm not sure
    how to fix it. The following line

        eqs\[i\].linea = line-linbuf\_base; /\* WinMerge

    move_line_detect */

    in find_and_hash_each_line(...) in IO.C assumes the line
    being added is from the left side, but I don't think this is
    necessarily so.

    However, I want to revamp this patch to match lines next to
    perfect matches anyway, rather than apply it as is. So I'm
    just recording this bug for posterity :)

  • Anonymous - 2004-02-06
    • assigned_to: nobody --> puddle
    • status: open --> closed-rejected
  • Anonymous - 2004-02-06

    Logged In: YES

    Rejecting, as I've entirely redone this, and am submitting a
    new patch#891498 (moved block detection).


Log in to post a comment.