mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Make TokenizedBuffer behave consistently when tokenizeInBackground is mocked
This commit is contained in:
@@ -7,6 +7,7 @@ fs = require 'fs-plus'
|
||||
Grim = require 'grim'
|
||||
pathwatcher = require 'pathwatcher'
|
||||
FindParentDir = require 'find-parent-dir'
|
||||
{CompositeDisposable} = require 'event-kit'
|
||||
|
||||
TextEditor = require '../src/text-editor'
|
||||
TextEditorElement = require '../src/text-editor-element'
|
||||
@@ -102,6 +103,18 @@ beforeEach ->
|
||||
TokenizedBuffer.prototype.chunkSize = Infinity
|
||||
spyOn(TokenizedBuffer.prototype, "tokenizeInBackground").andCallFake -> @tokenizeNextChunk()
|
||||
|
||||
# Without this spy, TextEditor.onDidTokenize callbacks would not be called
|
||||
# after the buffer's language mode changed, because by the time the editor
|
||||
# called its new language mode's onDidTokenize method, the language mode
|
||||
# would already be fully tokenized.
|
||||
spyOn(TextEditor.prototype, "onDidTokenize").andCallFake (callback) ->
|
||||
new CompositeDisposable(
|
||||
@emitter.on("did-tokenize", callback),
|
||||
@onDidChangeGrammar =>
|
||||
if @buffer.getLanguageMode().tokenizeInBackground.originalValue
|
||||
callback()
|
||||
)
|
||||
|
||||
clipboardContent = 'initial clipboard content'
|
||||
spyOn(clipboard, 'writeText').andCallFake (text) -> clipboardContent = text
|
||||
spyOn(clipboard, 'readText').andCallFake -> clipboardContent
|
||||
|
||||
Reference in New Issue
Block a user