Editor::isBufferRowCommented not working on first load?



I’m getting my hands dirty with a little package called color-gutter and I recently added a setting to ignore commented lines, partly to start playing with settings and partly because I found the method Editor::isBufferRowCommented while browsing the docs.

I’m having an issue where it seems like this method isn’t working properly when I Window: Reload. When I reload, the currently open tab seems to get commented lines properly, but when I go to any other tabs that I had open it doesn’t find any of the commented lines. I’ve verified through some logging that my Setting is toggling and reading current status properly, and that it’s definitely this method that is not returning true for any of the lines.

I’m seeing this using Atom 0.120.0 on both Mac and Ubuntu Linux.


This method relies on tokens, which are created asynchronously, hence the issue if your code try to know if a line is commented before the tokenized buffer have been completely initialized.


You should try to hook onto the tokenized event on the displayBuffer of the editor prior to any access to methods that uses tokens.


Cheers! That’s perfect, I’ll have a look at implementing that later.