Skip to content

Commit 20d6391

Browse files
committed
teeny
1 parent 5502360 commit 20d6391

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎v3/js/opt-live.js‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,23 @@ function updateStepLabels() {
212212
}
213213
}
214214

215+
var lineToScrollTo = null;
216+
if (myVisualizer.curLineNumber) {
217+
lineToScrollTo = myVisualizer.curLineNumber;
218+
} else if (myVisualizer.prevLineNumber) {
219+
lineToScrollTo = myVisualizer.prevLineNumber;
220+
}
221+
215222
// scroll the Ace editor to try to center the current line, but make
216223
// sure not to appear jarring, so apply some heuristics here
217224
// such as disableRowScrolling and checking to see if the current line
218225
// is visible
219-
if (myVisualizer.curLineNumber && !disableRowScrolling) {
226+
if (lineToScrollTo && !disableRowScrolling) {
220227
var firstVisible = pyInputAceEditor.getFirstVisibleRow() + 1; // +1 to be more accurate
221228
var lastVisible = pyInputAceEditor.getLastVisibleRow();
222-
if (myVisualizer.curLineNumber < firstVisible ||
223-
myVisualizer.curLineNumber > lastVisible) {
224-
pyInputAceEditor.scrollToLine(myVisualizer.curLineNumber, true /* try to center */);
229+
if (lineToScrollTo < firstVisible ||
230+
lineToScrollTo > lastVisible) {
231+
pyInputAceEditor.scrollToLine(lineToScrollTo, true /* try to center */);
225232
}
226233
}
227234
}

0 commit comments

Comments
 (0)