rehighlight the file when document changes resulted in no psi changes

This commit is contained in:
peter
2014-06-29 18:47:49 +02:00
parent ab7c994bd3
commit 264aa3fa81
@@ -40,6 +40,7 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl;
import com.intellij.psi.impl.PsiDocumentTransactionListener;
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
@@ -101,7 +102,17 @@ public class PsiChangeHandler extends PsiTreeChangeAdapter implements Disposable
private void updateChangesForDocument(@NotNull final Document document) {
if (DaemonListeners.isUnderIgnoredAction(null)) return;
List<Pair<PsiElement, Boolean>> toUpdate = changedElements.get(document);
if (toUpdate == null) return;
if (toUpdate == null) {
// The document has been changed, but psi hasn't
// We may still need to rehighlight the file if there were changes inside highlighted ranges.
if (UpdateHighlightersUtil.isWhitespaceOptimizationAllowed(document)) return;
// don't create PSI for files in other projects
PsiElement file = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
if (file == null) return;
toUpdate = ContainerUtil.newArrayList(Pair.create(file, true));
}
Application application = ApplicationManager.getApplication();
final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if (editor != null && !application.isUnitTestMode()) {