MergeOperation is created with fixed TextRange, so it will not be updated on change, like RangeHighlighters (and usage of RangeHighlighter is dangerous, as it could be updated incorrectly)
So we have to disable all actions until diff rebuild to prevent document corruption.
The 'right' fix of this issue could be to store line numbers inside action, update them on document change (like in LST), and use Document.getLineStartOffset() and etc inside write action.
public void beforeDocumentChange(DocumentEvent event) {}
public void documentChanged(DocumentEvent event) {
- int newLines = StringUtil.getLineBreakCount(event.getNewFragment());
- int oldLines = StringUtil.getLineBreakCount(event.getOldFragment());
- if (newLines != oldLines) myPanel.invalidateDiff();
+ if (event.getOldLength() != event.getNewLength()) myPanel.invalidateDiff();
requestRediff();
}