Skip to content

Commit abd764c

Browse files
committed
Solving scrolling issue
1 parent 33a534c commit abd764c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/com/reveal/codetimemachine/Commits3DView.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import com.github.mauricioaniche.ck.CKNumber;
44
import com.intellij.openapi.application.ApplicationManager;
55
import com.intellij.openapi.command.CommandProcessor;
6-
import com.intellij.openapi.editor.Document;
7-
import com.intellij.openapi.editor.EditorFactory;
8-
import com.intellij.openapi.editor.EditorSettings;
6+
import com.intellij.openapi.editor.*;
97
import com.intellij.openapi.editor.ex.EditorEx;
108
import com.intellij.openapi.fileEditor.FileDocumentManager;
119
import com.intellij.openapi.fileTypes.FileType;
@@ -945,9 +943,17 @@ private void loadMainEditorWindowContent()
945943
public void run()
946944
{
947945
mainEditorWindow.setText(content);
948-
mainEditorWindow.getEditor().getScrollingModel().scroll(0,0);
946+
//mainEditorWindow.setCaretPosition(0);
947+
if(mainEditorWindow.getEditor()!=null)
948+
{
949+
// We scroll top after each setText(..) (that make scroll go down). But we don't like to be animated.
950+
// Calling this once in initialization of Editor doesn't work. so we call it every time before scrolling.
951+
mainEditorWindow.getEditor().getScrollingModel().disableAnimation();
952+
mainEditorWindow.getEditor().getScrollingModel().scroll(0, 0);
953+
}
949954
// To solve the white screen problem (earlier, I resized the window to solve the problem)
950955
mainEditorWindow.revalidate();
956+
951957
}
952958
});
953959

0 commit comments

Comments
 (0)