Memoize comment scope selector

This commit is contained in:
Kevin Sawicki
2014-09-15 12:57:53 -07:00
parent 274a36e263
commit 804f290cd3

View File

@@ -1365,7 +1365,8 @@ class Editor extends Model
isBufferRowCommented: (bufferRow) ->
if match = @lineTextForBufferRow(bufferRow).match(/\S/)
scopes = @tokenForBufferPosition([bufferRow, match.index]).scopes
new TextMateScopeSelector('comment.*').matches(scopes)
@commentScopeSelector ?= new TextMateScopeSelector('comment.*')
@commentScopeSelector.matches(scopes)
# Public: Toggle line comments for rows intersecting selections.
#