import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
* @param startOffset start offset of the first line to check for wrapping (inclusive)
* @param endOffset end offset of the first line to check for wrapping (exclusive)
*/
- private void wrapLongLinesIfNecessary(@NotNull PsiFile file, @NotNull final Document document, final int startOffset,
+ private void wrapLongLinesIfNecessary(@NotNull PsiFile file, @Nullable final Document document, final int startOffset,
final int endOffset)
{
if (!mySettings.WRAP_LONG_LINES || file.getViewProvider().isLockedByPsiOperations()) {
Editor editor = PsiUtilBase.findEditor(file);
EditorFactory editorFactory = null;
if (editor == null) {
- if (!ApplicationManager.getApplication().isDispatchThread()) {
+ if (document == null || !ApplicationManager.getApplication().isDispatchThread()) {
return;
}
editorFactory = EditorFactory.getInstance();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
- doWrapLongLinesIfNecessary(editorToUse, document, startOffset, endOffset);
+ doWrapLongLinesIfNecessary(editorToUse, editorToUse.getDocument(), startOffset, endOffset);
}
});
}