How to handle multi-line comments in a live syntax highlighter?
问题 I'm writing my own text editor with syntax highlighting in Java, and at the moment it simply parses and highlights the current line every time the user enters a single character. While presumably not the most efficient way, it's good enough and doesn't cause any noticeable performance issues. In pseudo-Java, this would be the core concept of my code: public void textUpdated(String wholeText, int updateOffset, int updateLength) { int lineStart = getFirstLineStart(wholeText, updateOffset); int