EA-43416 - NPE: TextEditorProvider.getStateImpl

This commit is contained in:
Alexey Kudravtsev
2013-06-25 08:58:01 +04:00
parent e76e3994f7
commit fb77f34252
4 changed files with 8 additions and 5 deletions
@@ -527,6 +527,7 @@ public class EditorWindow extends UserDataHolderBase implements EditorEx {
return myDelegate.getContentSize();
}
@NotNull
@Override
public JScrollPane getScrollPane() {
return myDelegate.getScrollPane();
@@ -111,6 +111,7 @@ public interface EditorEx extends Editor {
void setOneLineMode(boolean b);
@NotNull
JScrollPane getScrollPane();
boolean isRendererMode();
@@ -250,9 +250,8 @@ public class ScrollingModelImpl implements ScrollingModelEx {
@Nullable
public JScrollBar getVerticalScrollBar() {
assertIsDispatchThread();
if (myEditor.getScrollPane() == null) return null;
return myEditor.getScrollPane().getVerticalScrollBar();
JScrollPane scrollPane = myEditor.getScrollPane();
return scrollPane.getVerticalScrollBar();
}
@Nullable
@@ -202,9 +202,10 @@ public class TextEditorProvider implements FileEditorProvider, DumbAware {
state.VERTICAL_SCROLL_PROPORTION = level == FileEditorStateLevel.UNDO ? -1 : EditorUtil.calcVerticalScrollProportion(editor);
if (editor instanceof EditorEx) {
state.VERTICAL_SCROLL_OFFSET = editor.getScrollingModel().getVerticalScrollOffset();
state.MAX_VERTICAL_SCROLL_OFFSET = ((EditorEx)editor).getScrollPane().getVerticalScrollBar().getMaximum();
JScrollBar scrollBar = ((EditorEx)editor).getScrollPane().getVerticalScrollBar();
state.MAX_VERTICAL_SCROLL_OFFSET = scrollBar == null ? 0 : scrollBar.getMaximum();
}
return state;
}
@@ -216,6 +217,7 @@ public class TextEditorProvider implements FileEditorProvider, DumbAware {
boolean preciselyScrollVertically =
state.VERTICAL_SCROLL_OFFSET > 0
&& editorEx != null
&& editorEx.getScrollPane().getVerticalScrollBar() != null
&& editorEx.getScrollPane().getVerticalScrollBar().getMaximum() == state.MAX_VERTICAL_SCROLL_OFFSET;
if (preciselyScrollVertically) {
editor.getScrollingModel().scrollVertically(state.VERTICAL_SCROLL_OFFSET);