for (var i = from; i < sel.to.line; ++i)
        endch += lineSep.length + lines[i].text.length;