Use global rootView in GoToLineView

This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-02-08 12:13:12 -08:00
parent 659c6bbd56
commit adb867cbd1
2 changed files with 9 additions and 11 deletions

View File

@@ -6,15 +6,15 @@ Point = require 'point'
module.exports =
class GoToLineView extends View
@activate: (rootView) -> new GoToLineView(rootView)
@activate: -> new GoToLineView
@content: ->
@div class: 'go-to-line overlay from-top mini', =>
@subview 'miniEditor', new Editor(mini: true)
@div class: 'message', outlet: 'message'
initialize: (@rootView) ->
@rootView.command 'editor:go-to-line', '.editor', => @toggle()
initialize: ->
rootView.command 'editor:go-to-line', '.editor', => @toggle()
@miniEditor.on 'focusout', => @detach()
@on 'core:confirm', => @confirm()
@on 'core:cancel', => @detach()
@@ -50,6 +50,6 @@ class GoToLineView extends View
attach: ->
@previouslyFocusedElement = $(':focus')
@rootView.append(this)
@message.text("Enter a line number 1-#{@rootView.getActiveEditor().getLineCount()}")
rootView.append(this)
@message.text("Enter a line number 1-#{rootView.getActiveEditor().getLineCount()}")
@miniEditor.focus()

View File

@@ -1,16 +1,14 @@
RootView = require 'root-view'
GoToLineView = require 'go-to-line/lib/go-to-line-view'
describe 'GoToLine', ->
[rootView, goToLine, editor] = []
[goToLine, editor] = []
beforeEach ->
rootView = new RootView(require.resolve('fixtures/sample.js'))
new RootView(require.resolve('fixtures/sample.js'))
rootView.enableKeymap()
atom.loadPackage("go-to-line")
editor = rootView.getActiveEditor()
editor.trigger 'editor:go-to-line'
goToLine = rootView.find('.go-to-line').view()
editor.trigger 'editor:go-to-line'
goToLine = GoToLineView.activate()
editor.setCursorBufferPosition([1,0])
afterEach ->