Rename RootView.editors -> getEditors

This commit is contained in:
Nathan Sobo
2012-07-02 19:47:38 -06:00
parent bd5c1f8694
commit 9cae4d3d8f
5 changed files with 15 additions and 15 deletions

View File

@@ -23,8 +23,8 @@ describe "RootView", ->
describe "when pathToOpen references a file", ->
it "creates a project for the file's parent directory, then sets the document.title and opens the file in an editor", ->
expect(rootView.project.getPath()).toBe fs.directory(path)
expect(rootView.editors().length).toBe 1
expect(rootView.editors()[0]).toHaveClass 'active'
expect(rootView.getEditors().length).toBe 1
expect(rootView.getEditors()[0]).toHaveClass 'active'
expect(rootView.getActiveEditor().buffer.getPath()).toBe path
expect(rootView.getActiveEditor().editSessions.length).toBe 1
expect(document.title).toBe path
@@ -39,7 +39,7 @@ describe "RootView", ->
rootView.focus()
expect(rootView.project.getPath()).toBe path
expect(rootView.editors().length).toBe 0
expect(rootView.getEditors().length).toBe 0
expect(document.title).toBe path
describe "when called with view state data returned from a previous call to RootView.prototype.serialize", ->
@@ -60,7 +60,7 @@ describe "RootView", ->
it "constructs the view with the same panes", ->
rootView = RootView.deserialize(viewState)
expect(rootView.project.getPath()?).toBeFalsy()
expect(rootView.editors().length).toBe 2
expect(rootView.getEditors().length).toBe 2
expect(rootView.getActiveEditor().buffer.getText()).toBe buffer.getText()
expect(document.title).toBe 'untitled'
@@ -89,7 +89,7 @@ describe "RootView", ->
rootView = RootView.deserialize(viewState)
rootView.attachToDom()
expect(rootView.editors().length).toBe 4
expect(rootView.getEditors().length).toBe 4
editor1 = rootView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = rootView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = rootView.panes.find('.row > .column > .pane .editor:eq(0)').view()
@@ -120,7 +120,7 @@ describe "RootView", ->
it "opens no buffer", ->
rootView.remove()
rootView = new RootView
expect(rootView.editors().length).toBe 0
expect(rootView.getEditors().length).toBe 0
expect(document.title).toBe 'untitled'
describe ".serialize()", ->
@@ -497,7 +497,7 @@ describe "RootView", ->
describe "when the last editor is removed", ->
it "updates the title to the project path", ->
rootView.editors()[0].remove()
rootView.getEditors()[0].remove()
expect(document.title).toBe rootView.project.getPath()
describe "font size adjustment", ->

View File

@@ -57,7 +57,7 @@ describe "Window", ->
it "unsubscribes from all buffers", ->
editor1 = rootView.getActiveEditor()
editor2 = editor1.splitRight()
expect(window.rootView.editors().length).toBe 2
expect(window.rootView.getEditors().length).toBe 2
$(window).trigger 'beforeunload'

View File

@@ -112,7 +112,7 @@ class RootView extends View
return true
if allowActiveEditorChange
for editor in @editors()
for editor in @getEditors()
if editor.activateEditSessionForPath(path)
editor.focus()
return true
@@ -142,19 +142,19 @@ class RootView extends View
setTitle: (title='untitled') ->
document.title = title
editors: ->
getEditors: ->
@panes.find('.editor').map(-> $(this).view()).toArray()
modifiedBuffers: ->
modifiedBuffers = []
for editor in @editors()
for editor in @getEditors()
for session in editor.editSessions
modifiedBuffers.push session.buffer if session.buffer.isModified()
modifiedBuffers
getOpenBufferPaths: ->
_.uniq(_.flatten(@editors().map (editor) -> editor.getOpenBufferPaths()))
_.uniq(_.flatten(@getEditors().map (editor) -> editor.getOpenBufferPaths()))
getActiveEditor: ->
if (editor = @panes.find('.editor.active')).length
@@ -182,7 +182,7 @@ class RootView extends View
rootPane?.adjustDimensions()
remove: ->
editor.remove() for editor in @editors()
editor.remove() for editor in @getEditors()
@project.destroy()
super

View File

@@ -5,7 +5,7 @@ class StatusBar extends View
@activate: (rootView) ->
requireStylesheet 'status-bar.css'
for editor in rootView.editors()
for editor in rootView.getEditors()
@appendToEditorPane(rootView, editor) if rootView.parents('html').length
rootView.on 'editor-open', (e, editor) =>

View File

@@ -25,7 +25,7 @@ class Autocomplete extends View
originalSelectedText: null
@activate: (rootView) ->
new Autocomplete(editor) for editor in rootView.editors()
new Autocomplete(editor) for editor in rootView.getEditors()
rootView.on 'editor-open', (e, editor) ->
new Autocomplete(editor) unless editor.is('.autocomplete .mini')