mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Update the status bar asynchronously on cursor move / buffer change
This keeps it out of the synchronous path from pressing a key to seeing it inserted on screen.
This commit is contained in:
parent
9bca73816c
commit
3fbf5653c4
@ -1,4 +1,5 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
RootView = require 'root-view'
|
||||
StatusBar = require 'status-bar'
|
||||
fs = require 'fs'
|
||||
@ -14,6 +15,10 @@ describe "StatusBar", ->
|
||||
statusBar = rootView.find('.status-bar').view()
|
||||
buffer = editor.getBuffer()
|
||||
|
||||
# updating the status bar is asynchronous for performance reasons
|
||||
# for testing purposes, make it synchronous
|
||||
spyOn(_, 'defer').andCallFake (fn) -> fn()
|
||||
|
||||
afterEach ->
|
||||
rootView.remove()
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
{View} = require 'space-pen'
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class StatusBar extends View
|
||||
@ -29,15 +30,15 @@ class StatusBar extends View
|
||||
@updatePathText()
|
||||
|
||||
@updateCursorPositionText()
|
||||
@editor.on 'cursor-move', => @updateCursorPositionText()
|
||||
@editor.on 'cursor-move', => _.defer => @updateCursorPositionText()
|
||||
|
||||
@subscribeToBuffer()
|
||||
|
||||
subscribeToBuffer: ->
|
||||
@buffer?.off '.status-bar'
|
||||
@buffer = @editor.getBuffer()
|
||||
@buffer.on 'change.status-bar', => @updateBufferModifiedText()
|
||||
@buffer.on 'after-save.status-bar', => @updateBufferModifiedText()
|
||||
@buffer.on 'change.status-bar', => _.defer => @updateBufferModifiedText()
|
||||
@buffer.on 'after-save.status-bar', => _.defer => @updateBufferModifiedText()
|
||||
@updateBufferModifiedText()
|
||||
|
||||
updateBufferModifiedText: ->
|
||||
|
Loading…
Reference in New Issue
Block a user