As JS uses swallow copies for strings, it'd be better to do <code>line = line.slice(0, cursor.ch)</code> instead of creating a new array.