Fix NRE exception on syntax coloring

Close #564.
Merge pull request #614 from dungpa/fix-nre

Fix NRE exception on syntax coloring