use of org.rstudio.studio.client.workbench.views.source.model.SourcePosition in project rstudio by rstudio.
the class AceEditor method navigate.
private void navigate(SourcePosition srcPosition, boolean addToHistory, boolean highlightLine) {
// get existing cursor position
Position previousCursorPos = getCursorPosition();
// set cursor to function line
Position position = Position.create(srcPosition.getRow(), srcPosition.getColumn());
setCursorPosition(position);
// skip whitespace if necessary
if (srcPosition.getColumn() == 0) {
int curRow = getSession().getSelection().getCursor().getRow();
String line = getSession().getLine(curRow);
int funStart = line.indexOf(line.trim());
position = Position.create(curRow, funStart);
setCursorPosition(position);
}
// scroll as necessary
if (srcPosition.getScrollPosition() != -1)
scrollToY(srcPosition.getScrollPosition(), 0);
else if (position.getRow() != previousCursorPos.getRow())
moveCursorNearTop();
else
ensureCursorVisible();
// set focus
focus();
if (highlightLine)
applyLineHighlight(position.getRow());
// supports history navigation
if (addToHistory)
fireRecordNavigationPosition(position);
}
Aggregations