mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
EA-35306 - assert: CaretModelImpl.moveToOffset
Debug check is added
This commit is contained in:
@@ -439,14 +439,14 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
|
||||
if (column < 0) {
|
||||
if (debugBuffer != null) {
|
||||
debugBuffer.append("Resetting target logical column to zero as it is negative (" + column + ")\n");
|
||||
debugBuffer.append("Resetting target logical column to zero as it is negative (").append(column).append(")\n");
|
||||
}
|
||||
column = 0;
|
||||
softWrapColumns = 0;
|
||||
}
|
||||
if (line < 0) {
|
||||
if (debugBuffer != null) {
|
||||
debugBuffer.append("Resetting target logical line to zero as it is negative (" + line + ")\n");
|
||||
debugBuffer.append("Resetting target logical line to zero as it is negative (").append(line).append(")\n");
|
||||
}
|
||||
line = 0;
|
||||
softWrapLinesBefore = 0;
|
||||
|
||||
+41
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl.softwrap.mapping;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.impl.EditorTextRepresentationHelper;
|
||||
import com.intellij.openapi.editor.impl.softwrap.SoftWrapDataMapper;
|
||||
import com.intellij.openapi.editor.impl.softwrap.SoftWrapImpl;
|
||||
@@ -54,7 +56,8 @@ import java.util.List;
|
||||
* @since Aug 31, 2010 10:24:47 AM
|
||||
*/
|
||||
public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAwareDocumentParsingListener {
|
||||
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + CachingSoftWrapDataMapper.class.getName());
|
||||
private static final boolean DEBUG_SOFT_WRAP_PROCESSING = false;
|
||||
|
||||
/** Caches information for the document visual line starts sorted in ascending order. */
|
||||
@@ -445,6 +448,30 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
|
||||
myCache.addAll(myNotAffectedByUpdateTailCacheEntries);
|
||||
}
|
||||
applyStateChange(exactOffsetsDiff);
|
||||
|
||||
// TODO den remove before v.12 release
|
||||
if (myCache.size() > 1) {
|
||||
CacheEntry beforeLast = myCache.get(myCache.size() - 2);
|
||||
CacheEntry last = myCache.get(myCache.size() - 1);
|
||||
if (beforeLast.visualLine == last.visualLine
|
||||
|| (beforeLast.visualLine + 1 == last.visualLine && last.startOffset - beforeLast.endOffset > 1)
|
||||
|| last.startOffset > myEditor.getDocument().getTextLength())
|
||||
{
|
||||
CharSequence editorState = "";
|
||||
if (myEditor instanceof EditorImpl) {
|
||||
editorState = ((EditorImpl)myEditor).dumpState();
|
||||
}
|
||||
LOG.error(
|
||||
"Detected invalid soft wraps cache update",
|
||||
String.format(
|
||||
"Event: %s, normal: %b.%n%nTail cache entries: %s%n%nAffected by change cache entries: %s%n%nBefore change state: %s%n%n"
|
||||
+ "After change state: %s%n%nEditor state: %s",
|
||||
event, normal, myNotAffectedByUpdateTailCacheEntries, myAffectedByUpdateCacheEntries,
|
||||
myBeforeChangeState, myAfterChangeState, editorState
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
myAffectedByUpdateCacheEntries.clear();
|
||||
myNotAffectedByUpdateTailCacheEntries.clear();
|
||||
@@ -610,14 +637,24 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
|
||||
public void rawAdd(int visualLine,
|
||||
int startOffset,
|
||||
int endOffset,
|
||||
int startLogicalLine,
|
||||
int startLogicalColumn,
|
||||
int endLogicalLine,
|
||||
int endLogicalColumn,
|
||||
int endVisualColumn,
|
||||
@NotNull List<Trinity<Integer, Integer, FoldRegion>> foldRegions,
|
||||
@NotNull List<Pair<Integer, Integer>> tabData)
|
||||
{
|
||||
final CacheEntry entry = new CacheEntry(visualLine, myEditor, myRepresentationHelper);
|
||||
entry.startOffset = startOffset;
|
||||
entry.endOffset = endOffset;
|
||||
entry.startLogicalLine = myEditor.getDocument().getLineNumber(startOffset);
|
||||
entry.endLogicalLine = myEditor.getDocument().getLineNumber(endOffset);
|
||||
entry.startLogicalLine = startLogicalLine;
|
||||
assert startLogicalLine == myEditor.getDocument().getLineNumber(startOffset);
|
||||
entry.startLogicalColumn = startLogicalColumn;
|
||||
entry.endLogicalLine = endLogicalLine;
|
||||
assert endLogicalLine == myEditor.getDocument().getLineNumber(endOffset);
|
||||
entry.endLogicalColumn = endLogicalColumn;
|
||||
entry.endVisualColumn = endVisualColumn;
|
||||
for (Trinity<Integer, Integer, FoldRegion> region : foldRegions) {
|
||||
final FoldingData foldData = new FoldingData(region.third, region.second, myRepresentationHelper, myEditor);
|
||||
foldData.widthInColumns = region.first;
|
||||
|
||||
+11
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -151,7 +151,8 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
protected static void setupSoftWraps(@NotNull String data) {
|
||||
Scanner scanner = new Scanner(data);
|
||||
Pattern generalPattern =
|
||||
Pattern.compile("visual line: (\\d+), offsets: (\\d+)-(\\d+), fold regions: \\[([^\\]]*)\\], tab data: \\[([^\\]]*)\\]");
|
||||
Pattern.compile("visual line: (\\d+), offsets: (\\d+)-(\\d+), logical lines: (\\d+)-(\\d+), logical columns: (\\d+)-(\\d+), "
|
||||
+ "end visual column: (\\d+), fold regions: \\[([^\\]]*)\\], tab data: \\[([^\\]]*)\\]");
|
||||
Pattern foldPattern = Pattern.compile("width in columns: (-?\\d+), start X: (-?\\d+), fold region: FoldRegion [-+]\\((\\d+):(\\d+)");
|
||||
Pattern tabPattern = Pattern.compile("\\[(\\d+), width: (\\d+)");
|
||||
final SoftWrapModelImpl softWrapModel = (SoftWrapModelImpl)myEditor.getSoftWrapModel();
|
||||
@@ -163,9 +164,14 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
int visualLine = Integer.parseInt(generalMatch.group(1));
|
||||
int startOffset = Integer.parseInt(generalMatch.group(2));
|
||||
int endOffset = Integer.parseInt(generalMatch.group(3));
|
||||
int startLogicalLine = Integer.parseInt(generalMatch.group(4));
|
||||
int endLogicalLine = Integer.parseInt(generalMatch.group(5));
|
||||
int startLogicalColumn = Integer.parseInt(generalMatch.group(6));
|
||||
int endLogicalColumn = Integer.parseInt(generalMatch.group(7));
|
||||
int endVisualColumn = Integer.parseInt(generalMatch.group(8));
|
||||
|
||||
List<Trinity<Integer, Integer, FoldRegion>> foldRegions = new ArrayList<Trinity<Integer, Integer, FoldRegion>>();
|
||||
Scanner foldScanner = new Scanner(generalMatch.group(4));
|
||||
Scanner foldScanner = new Scanner(generalMatch.group(9));
|
||||
while (foldScanner.findInLine(foldPattern) != null) {
|
||||
final MatchResult foldMatch = foldScanner.match();
|
||||
int widthInColumns = Integer.parseInt(foldMatch.group(1));
|
||||
@@ -183,7 +189,7 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
}
|
||||
|
||||
List<Pair<Integer, Integer>> tabData = new ArrayList<Pair<Integer, Integer>>();
|
||||
Scanner tabScanner = new Scanner(generalMatch.group(5));
|
||||
Scanner tabScanner = new Scanner(generalMatch.group(10));
|
||||
while (tabScanner.findInLine(tabPattern) != null) {
|
||||
final MatchResult tabMatch = tabScanner.match();
|
||||
int offset = Integer.parseInt(tabMatch.group(1));
|
||||
@@ -191,7 +197,7 @@ public abstract class AbstractEditorProcessingOnDocumentModificationTest extends
|
||||
tabData.add(new Pair<Integer, Integer>(offset, widthInColumns));
|
||||
}
|
||||
|
||||
mapper.rawAdd(visualLine, startOffset, endOffset, foldRegions, tabData);
|
||||
mapper.rawAdd(visualLine, startOffset, endOffset, startLogicalLine, startLogicalColumn, endLogicalLine, endLogicalColumn, endVisualColumn, foldRegions, tabData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user