Skip to content

Commit

Permalink
When executing Next chunk, scroll it near top
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Mar 27, 2012
1 parent c89b17f commit 430acd1
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -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())
Expand Down

0 comments on commit 430acd1

Please sign in to comment.