Moved Code

SemanticDiff can detect when code has been moved within a file and whether the moved code block contains additional changes.

For a code block to be detected as moved, it must cover at least one complete line. Moved code blocks are displayed with a border around the old and new code. The border color is different for each move to help you distinguish them.

Complete mode

Source and target

The source and target are connected by a line drawn across the middle bar. If the move source and target are far apart, this line is replaced by a shortened dotted line:

SemanticDiff - Far move

This line is mostly used to indicate the direction of a move. You can jump directly to the source or destination of a move by hovering over the code block and clicking the arrow in the upper right corner:

SemanticDiff - Far move

You can also see the source and destination of a move in the minimap. Just look out for a block that has the same color as the border around the move:

SemanticDiff - Far move

Changes inside moved code

By default, the source of the move is simply shown as one large deletion and the target as one large addition. If you want to see the changes inside a moved code block, you need to click the text button labeled Compare With Original above the target. This will switch the visualization to a compare mode:

SemanticDiff - Move with compare

The left side of the diff now displays a copy of the original code and you can see which parts have been deleted and added. You can hide the comparison again by clicking the Hide Comparison text button.

If the code was moved without changes, these buttons are not available. Instead you will find the text Moved without changes in italics above the move target:

SemanticDiff - Move with changes

If you want to see all moves in compare mode by default, you can change this in the options menu.