Dropping fold regions info on console clearing (use to provide invalid fold regions at the EA)

This commit is contained in:
Denis.Zhdanov
2012-04-06 12:43:07 +04:00
parent ddbc9d9b69
commit 2e312f232d
2 changed files with 21 additions and 9 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 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.
@@ -40,6 +40,7 @@ import com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction;
import com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
@@ -326,6 +327,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
myContentSize = 0;
myBuffer.clear();
myHyperlinks.clearHyperlinks();
myFolding.clear();
}
if (myFlushAlarm.isDisposed()) return;
cancelAllFlushRequests();
@@ -573,25 +575,31 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
if (myProject.isDisposed()) {
return;
}
if (myEditor == null) {
EditorEx editor = myEditor;
if (editor == null) {
//already disposed
return;
}
if (clear) {
final Document document;
final DocumentEx document;
synchronized (LOCK) {
myHyperlinks.clearHyperlinks();
myTokens.clear();
if (myEditor == null) return;
myEditor.getMarkupModel().removeAllHighlighters();
document = myEditor.getDocument();
editor.getMarkupModel().removeAllHighlighters();
document = editor.getDocument();
myFoldingAlarm.cancelAllRequests();
cancelHeavyAlarm();
}
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
document.deleteString(0, document.getTextLength());
document.setInBulkUpdate(true);
try {
document.deleteString(0, document.getTextLength());
}
finally {
document.setInBulkUpdate(false);
}
}
}, null, DocCommandGroupId.noneGroupId(document));
}
@@ -603,7 +611,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
synchronized (LOCK) {
if (myOutputPaused) return;
if (myBuffer.isEmpty()) return;
if (myEditor == null) return;
text = myBuffer.getText();
@@ -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.
@@ -20,6 +20,7 @@ import com.intellij.ide.CutProvider;
import com.intellij.ide.DeleteProvider;
import com.intellij.ide.PasteProvider;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.VisualPosition;
@@ -47,6 +48,10 @@ public interface EditorEx extends Editor {
@NonNls String PROP_FONT_SIZE = "fontSize";
Key<TextRange> LAST_PASTED_REGION = Key.create("LAST_PASTED_REGION");
@NotNull
@Override
DocumentEx getDocument();
@NotNull
EditorGutterComponentEx getGutterComponentEx();