From 430acd18d3b5d35659af74395f88f4640a99b2fb Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Tue, 27 Mar 2012 09:31:00 -0700 Subject: [PATCH] When executing Next chunk, scroll it near top --- .../source/editors/text/TextEditingTarget.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java b/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java index e10cdce82b0..2c618816741 100644 --- a/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java +++ b/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java @@ -1597,21 +1597,28 @@ void onInsertChunk() @Handler void onExecuteCurrentChunk() { - executeSweaveChunk(scopeHelper_.getCurrentSweaveChunk()); + executeSweaveChunk(scopeHelper_.getCurrentSweaveChunk(), false); } @Handler void onExecuteNextChunk() { - executeSweaveChunk(scopeHelper_.getNextSweaveChunk()); + executeSweaveChunk(scopeHelper_.getNextSweaveChunk(), true); } - private void executeSweaveChunk(Scope chunk) + private void executeSweaveChunk(Scope chunk, boolean scrollNearTop) { if (chunk == null) return; Range range = scopeHelper_.getSweaveChunkInnerRange(chunk); + if (scrollNearTop) + { + docDisplay_.navigateToPosition( + SourcePosition.create(range.getStart().getRow(), + range.getStart().getColumn()), + true); + } docDisplay_.setSelection( docDisplay_.createSelection(range.getStart(), range.getEnd())); if (!range.isEmpty())