mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Only tokenize in background if when a buffer is visible in an editor
This will prevent running a bunch of background tokenization when Atom is reloaded. We only perform tokenization to support content that is actually on screen.
This commit is contained in:
@@ -16,6 +16,7 @@ class TokenizedBuffer
|
||||
screenLines: null
|
||||
chunkSize: 50
|
||||
invalidRows: null
|
||||
visible: false
|
||||
|
||||
constructor: (@buffer, { @languageMode, @tabLength }) ->
|
||||
@tabLength ?= 2
|
||||
@@ -25,6 +26,9 @@ class TokenizedBuffer
|
||||
@invalidateRow(0)
|
||||
@buffer.on "change.tokenized-buffer#{@id}", (e) => @handleBufferChange(e)
|
||||
|
||||
setVisible: (@visible) ->
|
||||
@tokenizeInBackground() if @visible
|
||||
|
||||
getTabLength: ->
|
||||
@tabLength
|
||||
|
||||
@@ -35,7 +39,7 @@ class TokenizedBuffer
|
||||
@trigger "change", { start: 0, end: lastRow, delta: 0 }
|
||||
|
||||
tokenizeInBackground: ->
|
||||
return if @pendingChunk
|
||||
return if not @visible or @pendingChunk
|
||||
@pendingChunk = true
|
||||
_.defer =>
|
||||
@pendingChunk = false
|
||||
|
||||
Reference in New Issue
Block a user