if (!chunkText.isEmpty()) {
Line lastLine = document.getLastLine();
int lastColumn = lastLine.getText().length();
document.insertText(lastLine, document.getLastLineNumber(), lastColumn, chunkText);
Anchor anchor = document.getAnchorManager().createAnchor(
DIFF_CHUNK_ANCHOR_TYPE, lastLine, AnchorManager.IGNORE_LINE_NUMBER, lastColumn);
anchor.setValue(chunkStyles.get(chunkType.toString()));
// TODO Below is temp fix to ensure
// "Left should never have Green. Right should never have Red"
if (isBeforeFile) {
if (chunkType == DiffChunkResponse.DiffType.ADDED_LINE
|| chunkType == DiffChunkResponse.DiffType.ADDED) {
anchor.setValue(diffBlockStyle);
} else if (chunkType == DiffChunkResponse.DiffType.CHANGED) {
anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.REMOVED.toString()));
} else if (chunkType == DiffChunkResponse.DiffType.CHANGED_LINE) {
anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.REMOVED_LINE.toString()));
}
} else {
if (chunkType == DiffChunkResponse.DiffType.REMOVED
|| chunkType == DiffChunkResponse.DiffType.REMOVED_LINE) {
anchor.setValue(diffBlockStyle);
} else if (chunkType == DiffChunkResponse.DiffType.CHANGED) {
anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.ADDED.toString()));
} else if (chunkType == DiffChunkResponse.DiffType.CHANGED_LINE) {
anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.ADDED_LINE.toString()));
}
}
}
}