in src/executable-code/executable-fragment.js [548:567]
recalculatePosition(position) {
const newPosition = {
line: position.line,
ch: position.ch,
};
if (!this.state.folded) {
return newPosition;
}
let linesInPrefix = (this.prefix.match(/\n/g) || []).length;
newPosition.line = position.line - linesInPrefix;
if (newPosition.line < 0) {
newPosition.line = 0;
newPosition.ch = 0;
} else if (newPosition.line >= this.codemirror.lineCount()) {
newPosition.line = this.codemirror.lineCount() - 1;
newPosition.ch = null;
}
return newPosition;
}