mirror of
https://github.com/atom/atom.git
synced 2026-02-11 07:05:11 -05:00
SelectionViews now update their appearance immediately when constructed. We can't assume they're empty. CursorView doesn't do a blanket `off()` call to its model when it's removed anymore, which was screwing up selection updates when switching back. Only attach selections / cursors when the editor is attached, and extract everything we do into a `renderWhenAttached` method.
39 lines
1.0 KiB
CoffeeScript
39 lines
1.0 KiB
CoffeeScript
Buffer = require 'buffer'
|
|
Editor = require 'editor'
|
|
$ = require 'jquery'
|
|
_ = require 'underscore'
|
|
fs = require 'fs'
|
|
|
|
describe "Cursor", ->
|
|
[buffer, editor, cursorView, cursor] = []
|
|
|
|
beforeEach ->
|
|
buffer = new Buffer(require.resolve('fixtures/sample.js'))
|
|
editor = new Editor
|
|
editor.enableKeymap()
|
|
editor.setBuffer(buffer)
|
|
editor.attachToDom()
|
|
cursor = editor.getCursor()
|
|
cursorView = editor.getCursorView()
|
|
|
|
describe "adding and removing of the idle class", ->
|
|
it "removes the idle class while moving, then adds it back when it stops", ->
|
|
advanceClock(200)
|
|
|
|
expect(cursorView).toHaveClass 'idle'
|
|
cursor.setScreenPosition([1, 2])
|
|
expect(cursorView).not.toHaveClass 'idle'
|
|
|
|
window.advanceClock(200)
|
|
expect(cursorView).toHaveClass 'idle'
|
|
|
|
cursor.setScreenPosition([1, 3])
|
|
advanceClock(100)
|
|
|
|
cursor.setScreenPosition([1, 4])
|
|
advanceClock(100)
|
|
expect(cursorView).not.toHaveClass 'idle'
|
|
|
|
advanceClock(100)
|
|
expect(cursorView).toHaveClass 'idle'
|