mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-58070 Soft wrap: Improve soft wraps performance
Corrected situation with invalid recalculation range during incremental soft wraps cache update on removal at the last document line
This commit is contained in:
+16
@@ -76,6 +76,22 @@ public class SoftWrapImpl implements SoftWrap {
|
||||
myChange.advance(diff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myChange.hashCode();
|
||||
result = 31 * result + myIndentInColumns;
|
||||
return 31 * result + myIndentInPixels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SoftWrapImpl that = (SoftWrapImpl)o;
|
||||
return myIndentInColumns == that.myIndentInColumns && myIndentInPixels == that.myIndentInPixels && myChange.equals(that.myChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myChange.toString();
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ class IncrementalCacheUpdateEvent {
|
||||
}
|
||||
|
||||
private static int getLineStartOffset(int offset, Document document) {
|
||||
if (offset >= document.getTextLength()) {
|
||||
if (offset > document.getTextLength()) {
|
||||
return offset;
|
||||
}
|
||||
int lineNumber = document.getLineNumber(offset);
|
||||
|
||||
+15
@@ -24,6 +24,8 @@ import gnu.trove.TIntProcedure;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -240,6 +242,19 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP
|
||||
assertEquals(offset, caretModel.getOffset());
|
||||
}
|
||||
|
||||
public void testBackspaceAtTheEndOfSoftWrappedLine() throws IOException {
|
||||
// There was a problem that removing text from the last document line that was soft-wrapped removed soft wraps as well.
|
||||
String text =
|
||||
"This a long string that is expected to be wrapped in more than one visual line<caret>";
|
||||
init(150, text);
|
||||
|
||||
List<? extends SoftWrap> softWrapsBeforeModification = new ArrayList<SoftWrap>(getSoftWrapModel().getRegisteredSoftWraps());
|
||||
assertTrue(softWrapsBeforeModification.size() > 0);
|
||||
|
||||
backspace();
|
||||
assertEquals(softWrapsBeforeModification, getSoftWrapModel().getRegisteredSoftWraps());
|
||||
}
|
||||
|
||||
private static TIntHashSet collectSoftWrapStartOffsets(int documentLine) {
|
||||
TIntHashSet result = new TIntHashSet();
|
||||
for (SoftWrap softWrap : myEditor.getSoftWrapModel().getSoftWrapsForLine(documentLine)) {
|
||||
|
||||
Reference in New Issue
Block a user