Skip to content

Commit fe6763f

Browse files
committed
move to the right column on syntax error
1 parent 159d909 commit fe6763f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎v4-cokapi/frontends/js/opt-frontend-common.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,20 @@ function executeCodeWithRawInput(rawInputStr, curInstr) {
552552
function handleUncaughtExceptionFunc(trace) {
553553
if (trace.length == 1 && trace[0].line) {
554554
var errorLineNo = trace[0].line - 1; /* Ace lines are zero-indexed */
555-
if (errorLineNo !== undefined && errorLineNo != NaN) {
555+
if (errorLineNo !== undefined) {
556556
// highlight the faulting line
557557
var s = pyInputAceEditor.getSession();
558558
s.setAnnotations([{row: errorLineNo,
559559
type: 'error',
560560
text: trace[0].exception_msg}]);
561561
pyInputAceEditor.gotoLine(errorLineNo + 1 /* one-indexed */);
562+
// if we have both a line and column number, then move over to
563+
// that column. (going to the line first prevents weird
564+
// highlighting bugs)
565+
if (trace[0].col !== undefined) {
566+
pyInputAceEditor.moveCursorTo(errorLineNo, trace[0].col);
567+
}
568+
pyInputAceEditor.focus();
562569
}
563570
}
564571
}

0 commit comments

Comments
 (0)