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.
# atom/atom/blob/master/src/editor.coffee#L473-L476
isBufferRowCommented: (bufferRow) ->
if match = @lineForBufferRow(bufferRow).match(/\S/)
scopes = @tokenForBufferPosition([bufferRow, match.index]).scopes
new TextMateScopeSelector('comment.*').matches(scopes)
You should try to hook onto the tokenized event on the displayBuffer of the editor prior to any access to methods that uses tokens.
From https://discuss.atom.io/t/editor-isbufferrowcommented-not-working-on-first-load/11308/2?u=bkbooth
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.