mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-89180 - ISE: EditorView.offsetToVisualPosition
This commit is contained in:
@@ -825,7 +825,6 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable {
|
||||
|
||||
void afterDocumentChange(@NotNull final DocumentEventImpl event) {
|
||||
final DocumentEx document = myEditor.getDocument();
|
||||
if (document.isInBulkUpdate()) return;
|
||||
boolean performSoftWrapAdjustment = event.getNewLength() > 0 // We want to put caret just after the last added symbol
|
||||
// There is a possible case that the user removes text just before the soft wrap. We want to keep caret
|
||||
// on a visual line with soft wrap start then.
|
||||
|
||||
@@ -81,11 +81,13 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
|
||||
isDocumentChanged = true;
|
||||
try {
|
||||
myIsInUpdate = false;
|
||||
doWithCaretMerging(() -> {
|
||||
for (CaretImpl caret : myCarets) {
|
||||
caret.afterDocumentChange((DocumentEventImpl)e);
|
||||
}
|
||||
});
|
||||
if (!myEditor.getDocument().isInBulkUpdate()) {
|
||||
doWithCaretMerging(() -> {
|
||||
for (CaretImpl caret : myCarets) {
|
||||
caret.afterDocumentChange((DocumentEventImpl)e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
finally {
|
||||
isDocumentChanged = false;
|
||||
|
||||
@@ -137,6 +137,29 @@ public class EditorImplTest extends AbstractEditorTest {
|
||||
checkResultByText("something\telse");
|
||||
}
|
||||
|
||||
public void testCaretMergeDuringBulkModeDocumentUpdate() throws Exception {
|
||||
initText("a<selection>bcdef<caret></selection>g\n" +
|
||||
"a<selection>bcdef<caret></selection>g");
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
DocumentEx document = (DocumentEx)myEditor.getDocument();
|
||||
document.setInBulkUpdate(true);
|
||||
try {
|
||||
// delete selected text
|
||||
document.deleteString(1, 6);
|
||||
document.deleteString(4, 9);
|
||||
}
|
||||
finally {
|
||||
document.setInBulkUpdate(false);
|
||||
}
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
checkResultByText("a<caret>g\n" +
|
||||
"a<caret>g");
|
||||
}
|
||||
|
||||
public void testPositionCalculationForOneCharacterFolds() throws Exception {
|
||||
initText("something");
|
||||
addCollapsedFoldRegion(1, 2, "...");
|
||||
|
||||
Reference in New Issue
Block a user