IDEA-123286 diff: fix off-by-one in the current document too

This commit is contained in:
Aleksey Pivovarov
2014-04-02 12:01:40 +04:00
parent d281c91fac
commit 6b4ad69ecd
2 changed files with 12 additions and 5 deletions

View File

@@ -613,6 +613,10 @@ public class LineStatusTracker {
return getRange(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument, false);
}
TextRange getCurrentTextRangeWithEndSymbol(Range range) {
return getRange(range.getType(), range.getOffset1(), range.getOffset2(), Range.DELETED, myDocument, true);
}
// a hack
TextRange getUpToDateRangeWithEndSymbol(Range range) {
return getRange(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument, true);

View File

@@ -27,8 +27,8 @@ import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* @author irengrig
*/
* @author irengrig
*/
public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
public ShowLineStatusRangeDiffAction(final LineStatusTracker lineStatusTracker, final Range range, final Editor editor) {
super(VcsBundle.message("action.name.show.difference"), AllIcons.Actions.Diff, lineStatusTracker, range);
@@ -54,9 +54,12 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
return new DiffRequest(myLineStatusTracker.getProject()) {
@NotNull
public DiffContent[] getContents() {
return new DiffContent[]{createDiffContent(myLineStatusTracker.getUpToDateDocument(),
myLineStatusTracker.getUpToDateRangeWithEndSymbol(myRange), null),
createDiffContent(myLineStatusTracker.getDocument(), myLineStatusTracker.getCurrentTextRange(myRange),
return new DiffContent[]{
createDiffContent(myLineStatusTracker.getUpToDateDocument(),
myLineStatusTracker.getUpToDateRangeWithEndSymbol(myRange),
null),
createDiffContent(myLineStatusTracker.getDocument(),
myLineStatusTracker.getCurrentTextRangeWithEndSymbol(myRange),
myLineStatusTracker.getVirtualFile())};
}