code-assist: cleanup line rendering

also fixes a very bad long loop in the case that line is -1.