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
1. Enforcing soft wraps cache population with entry for lines that contain tabulation symbol; 2. Corrected incremental soft wraps update on fold region collapsing/expanding;
This commit is contained in:
+2
-1
@@ -285,7 +285,7 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
|
||||
|
||||
@Override
|
||||
public void onTabulation(@NotNull EditorPosition position, int widthInColumns) {
|
||||
CacheEntry cacheEntry = getCacheEntryForVisualLine(position.visualLine, true);
|
||||
CacheEntry cacheEntry = getCacheEntryForVisualLine(position.visualLine, false);
|
||||
if (cacheEntry == null) {
|
||||
return;
|
||||
}
|
||||
@@ -600,6 +600,7 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
|
||||
CacheEntry cacheEntry = myCache.get(i);
|
||||
foldedLines += cacheEntry.endFoldedLines - cacheEntry.startFoldedLines;
|
||||
}
|
||||
visualLines -= foldedLines;
|
||||
|
||||
if (DEBUG_SOFT_WRAP_PROCESSING) {
|
||||
log(String.format("CachingSoftWrapDataMapper$CacheState.updateByDocumentOffsets(). Collected %d fold lines for cache entry indices "
|
||||
|
||||
+1
@@ -1004,6 +1004,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
|
||||
}
|
||||
int widthInColumns = calculateWidthInColumns(c, widthInPixels, myContext.spaceWidth);
|
||||
if (c == '\t') {
|
||||
notifyListenersOnVisualLineStart(myContext.lineStartPosition);
|
||||
notifyListenersOnTabulation(widthInColumns);
|
||||
}
|
||||
|
||||
|
||||
+25
-1
@@ -178,7 +178,7 @@ public class SoftWrapApplianceOnDocumentModificationTest extends LightPlatformCo
|
||||
// The main idea is to type on a logical line before soft wrap in order to ensure that its offset is correctly shifted back.
|
||||
String text =
|
||||
"line1<caret>\n" +
|
||||
"second line that is rather long to be soft wrapped";
|
||||
"second line that is long enough to be soft wrapped";
|
||||
init(100, text);
|
||||
|
||||
TIntHashSet offsetsBefore = collectSoftWrapStartOffsets(1);
|
||||
@@ -196,6 +196,30 @@ public class SoftWrapApplianceOnDocumentModificationTest extends LightPlatformCo
|
||||
});
|
||||
}
|
||||
|
||||
public void testSoftWrapAwareMappingAfterLeadingFoldRegionCollapsing() throws IOException {
|
||||
String text =
|
||||
"line to fold 1\n" +
|
||||
"line to fold 2\n" +
|
||||
"line to fold 3\n" +
|
||||
"ordinary line 1\n" +
|
||||
"ordinary line 2\n" +
|
||||
"ordinary line 3\n" +
|
||||
"ordinary line 4\n" +
|
||||
"line that is long enough to be soft wrapped\n" +
|
||||
"ordinary line 5\n" +
|
||||
"ordinary line 6\n" +
|
||||
"ordinary line 7\n" +
|
||||
"ordinary line 8\n";
|
||||
|
||||
init(200, text);
|
||||
LogicalPosition position = myEditor.visualToLogicalPosition(new VisualPosition(8, 0));
|
||||
assertSame(7, position.line); // Position from soft-wrapped part of the line
|
||||
|
||||
addFoldRegion(0, text.indexOf("ordinary line 1") - 1, "...");
|
||||
toggleFoldRegionState(myEditor.getFoldingModel().getAllFoldRegions()[0], false);
|
||||
assertSame(7, myEditor.visualToLogicalPosition(new VisualPosition(6, 0)).line); // Check that soft wraps cache is correctly updated
|
||||
}
|
||||
|
||||
//private void init(final int visibleWidth) throws Exception {
|
||||
// configureByFile(PATH + getFileName());
|
||||
// initCommon(visibleWidth);
|
||||
|
||||
Reference in New Issue
Block a user