mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-43416 - NPE: TextEditorProvider.getStateImpl
This commit is contained in:
@@ -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
|
||||
|
||||
+4
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user