我使用以下代码以String格式显示两个输入之间的区别
protected Object prepareInput(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
CompareItem left = new CompareItem(text1);
CompareItem right = new CompareItem(text2);
diffNode= new DiffNode(left, right);
return diffNode;
}
输入
line1 testline
line2 line1
line3 line2
line3
它显示所有行都不同,而不是仅显示第一行是不同的。
我调用比较编辑器的方式是
CompareUI.openCompareDialog(new MyCompare(configuration, ((MyEditor)
editorPart).originalText(), ((MyEditor) editorPart).currentConverted()) );
感谢您的帮助。
答案 0 :(得分:0)
这:
CompareConfiguration configuration = new CompareConfiguration();
CompareUI.openCompareDialog(new CompareEditorInput(configuration) {
@Override
protected Object prepareInput(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
String text1 = "line1\nline2\nline3\n";
String text2 = "testline\nline1\nline2\nline3\n";
CompareItem left = new CompareItem("1", text1);
CompareItem right = new CompareItem("2", text2);
DiffNode diffNode = new DiffNode(left, right);
return diffNode;
}
});
在开普勒身上非常适合我。
所以我认为你没有给我们足够的数据。