Merge pull request #1140 from atom/ks-remove-project-root-view-globals

Remove project/rootView globals
This commit is contained in:
Kevin Sawicki
2013-11-20 17:34:44 -08:00
34 changed files with 451 additions and 463 deletions

View File

@@ -245,7 +245,7 @@ $('ol.entries li.file.status-modified span.name').each (i, el) ->
parents.each (i, el) ->
filePath.unshift($(el).find('div.header span.name').eq(0).text())
modifiedFilePath = path.join(project.rootDirectory.path, filePath.join(path.sep))
modifiedFilePath = path.join(atom.project.rootDirectory.path, filePath.join(path.sep))
modifiedFiles.push modifiedFilePath
```

View File

@@ -71,41 +71,41 @@
"base16-tomorrow-dark-theme": "0.6.0",
"solarized-dark-syntax": "0.4.0",
"archive-view": "0.13.0",
"autocomplete": "0.14.0",
"autocomplete": "0.15.0",
"autoflow": "0.7.0",
"autosave": "0.7.0",
"bookmarks": "0.11.0",
"bookmarks": "0.12.0",
"bracket-matcher": "0.12.0",
"command-logger": "0.7.0",
"command-palette": "0.9.0",
"dev-live-reload": "0.16.0",
"editor-stats": "0.6.0",
"exception-reporting": "0.7.0",
"find-and-replace": "0.45.0",
"fuzzy-finder": "0.22.0",
"find-and-replace": "0.46.0",
"fuzzy-finder": "0.23.0",
"gists": "0.8.0",
"git-diff": "0.14.0",
"git-diff": "0.15.0",
"github-sign-in": "0.10.0",
"go-to-line": "0.8.0",
"grammar-selector": "0.10.0",
"image-view": "0.8.0",
"keybinding-resolver": "0.4.0",
"link": "0.8.0",
"markdown-preview": "0.18.0",
"markdown-preview": "0.19.0",
"metrics": "0.12.0",
"package-generator": "0.20.0",
"release-notes": "0.12.0",
"settings-view": "0.45.0",
"settings-view": "0.46.0",
"snippets": "0.15.0",
"spell-check": "0.14.0",
"status-bar": "0.20.0",
"styleguide": "0.11.0",
"symbols-view": "0.21.0",
"status-bar": "0.21.0",
"styleguide": "0.12.0",
"symbols-view": "0.22.0",
"tabs": "0.10.0",
"terminal": "0.18.0",
"timecop": "0.10.0",
"to-the-hubs": "0.11.0",
"tree-view": "0.34.0",
"to-the-hubs": "0.12.0",
"tree-view": "0.35.0",
"visual-bell": "0.4.0",
"whitespace": "0.9.0",
"wrap-guide": "0.6.0",

View File

@@ -15,14 +15,14 @@ describe "AtomPackage", ->
describe "when the theme contains a single style file", ->
it "loads and applies css", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
themePath = project.resolve('packages/theme-with-index-css')
themePath = atom.project.resolve('packages/theme-with-index-css')
theme = Package.load(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "1234px"
it "parses, loads and applies less", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
themePath = project.resolve('packages/theme-with-index-less')
themePath = atom.project.resolve('packages/theme-with-index-less')
theme = Package.load(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "4321px"
@@ -33,7 +33,7 @@ describe "AtomPackage", ->
expect($(".editor").css("padding-right")).not.toBe("102px")
expect($(".editor").css("padding-bottom")).not.toBe("103px")
themePath = project.resolve('packages/theme-with-package-file')
themePath = atom.project.resolve('packages/theme-with-package-file')
theme = Package.load(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe("101px")
@@ -46,7 +46,7 @@ describe "AtomPackage", ->
expect($(".editor").css("padding-right")).not.toBe "20px"
expect($(".editor").css("padding-bottom")).not.toBe "30px"
themePath = project.resolve('packages/theme-without-package-file')
themePath = atom.project.resolve('packages/theme-without-package-file')
theme = Package.load(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "10px"
@@ -55,7 +55,7 @@ describe "AtomPackage", ->
describe "reloading a theme", ->
beforeEach ->
themePath = project.resolve('packages/theme-with-package-file')
themePath = atom.project.resolve('packages/theme-with-package-file')
theme = Package.load(themePath)
theme.activate()
@@ -66,7 +66,7 @@ describe "AtomPackage", ->
describe "events", ->
beforeEach ->
themePath = project.resolve('packages/theme-with-package-file')
themePath = atom.project.resolve('packages/theme-with-package-file')
theme = Package.load(themePath)
theme.activate()

View File

@@ -5,7 +5,7 @@ ThemeManager = require '../src/theme-manager'
describe "the `atom` global", ->
beforeEach ->
window.rootView = new RootView
atom.rootView = new RootView
describe "package lifecycle methods", ->
describe ".loadPackage(name)", ->
@@ -90,12 +90,12 @@ describe "the `atom` global", ->
it "defers requiring/activating the main module until an activation event bubbles to the root view", ->
expect(pack.requireMainModule).not.toHaveBeenCalled()
expect(mainModule.activate).not.toHaveBeenCalled()
rootView.trigger 'activation-event'
atom.rootView.trigger 'activation-event'
expect(mainModule.activate).toHaveBeenCalled()
it "triggers the activation event on all handlers registered during activation", ->
rootView.openSync()
editorView = rootView.getActiveView()
atom.rootView.openSync()
editorView = atom.rootView.getActiveView()
eventHandler = jasmine.createSpy("activation-event")
editorView.command 'activation-event', eventHandler
editorView.trigger 'activation-event'

View File

@@ -6,7 +6,7 @@ describe "DisplayBuffer", ->
beforeEach ->
tabLength = 2
atom.packages.activatePackage('language-javascript', sync: true)
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
displayBuffer = new DisplayBuffer({buffer, tabLength})
changeHandler = jasmine.createSpy 'changeHandler'
displayBuffer.on 'changed', changeHandler
@@ -154,7 +154,7 @@ describe "DisplayBuffer", ->
describe "when a newline is inserted, deleted, and re-inserted at the end of a wrapped line (regression)", ->
it "correctly renders the original wrapped line", ->
buffer = project.buildBufferSync(null, '')
buffer = atom.project.buildBufferSync(null, '')
displayBuffer = new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30, softWrap: true})
buffer.insert([0, 0], "the quick brown fox jumps over the lazy dog.")
@@ -206,7 +206,7 @@ describe "DisplayBuffer", ->
beforeEach ->
displayBuffer.destroy()
buffer.release()
buffer = project.bufferForPathSync('two-hundred.txt')
buffer = atom.project.bufferForPathSync('two-hundred.txt')
displayBuffer = new DisplayBuffer({buffer, tabLength})
displayBuffer.on 'changed', changeHandler

View File

@@ -8,7 +8,7 @@ describe "Editor", ->
describe "with an initial line option", ->
beforeEach ->
editor = project.openSync('sample.js', initialLine: 2)
editor = atom.project.openSync('sample.js', initialLine: 2)
buffer = editor.buffer
it "opens the file and positions the cursor on line 2", ->
@@ -17,7 +17,7 @@ describe "Editor", ->
describe "with default options", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
buffer = editor.buffer
lineLengths = buffer.getLines().map (line) -> line.length
@@ -60,7 +60,7 @@ describe "Editor", ->
atom.config.set('editor.tabLength', 4)
atom.config.set('editor.softWrap', true)
atom.config.set('editor.softTabs', false)
editor1 = project.openSync('a')
editor1 = atom.project.openSync('a')
expect(editor1.getTabLength()).toBe 4
expect(editor1.getSoftWrap()).toBe true
expect(editor1.getSoftTabs()).toBe false
@@ -68,7 +68,7 @@ describe "Editor", ->
atom.config.set('editor.tabLength', 100)
atom.config.set('editor.softWrap', false)
atom.config.set('editor.softTabs', true)
editor2 = project.openSync('b')
editor2 = atom.project.openSync('b')
expect(editor2.getTabLength()).toBe 100
expect(editor2.getSoftWrap()).toBe false
expect(editor2.getSoftTabs()).toBe true
@@ -1184,7 +1184,7 @@ describe "Editor", ->
expect(selection.isEmpty()).toBeTruthy()
it "does not share selections between different edit sessions for the same buffer", ->
editor2 = project.openSync('sample.js')
editor2 = atom.project.openSync('sample.js')
editor.setSelectedBufferRanges([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
editor2.setSelectedBufferRanges([[[8, 7], [6, 5]], [[4, 3], [2, 1]]])
expect(editor2.getSelectedBufferRanges()).not.toEqual editor.getSelectedBufferRanges()
@@ -2036,7 +2036,7 @@ describe "Editor", ->
it "does not explode if the current language mode has no comment regex", ->
editor.destroy()
editor = project.openSync(null, autoIndent: false)
editor = atom.project.openSync(null, autoIndent: false)
editor.setSelectedBufferRange([[4, 5], [4, 5]])
editor.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
@@ -2358,13 +2358,13 @@ describe "Editor", ->
describe "soft-tabs detection", ->
it "assigns soft / hard tabs based on the contents of the buffer, or uses the default if unknown", ->
editor = project.openSync('sample.js', softTabs: false)
editor = atom.project.openSync('sample.js', softTabs: false)
expect(editor.getSoftTabs()).toBeTruthy()
editor = project.openSync('sample-with-tabs.coffee', softTabs: true)
editor = atom.project.openSync('sample-with-tabs.coffee', softTabs: true)
expect(editor.getSoftTabs()).toBeFalsy()
editor = project.openSync(null, softTabs: false)
editor = atom.project.openSync(null, softTabs: false)
expect(editor.getSoftTabs()).toBeFalsy()
describe ".indentLevelForLine(line)", ->
@@ -2393,7 +2393,7 @@ describe "Editor", ->
jsGrammar = atom.syntax.selectGrammar('a.js')
atom.syntax.removeGrammar(jsGrammar)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
expect(editor.getGrammar()).toBe atom.syntax.nullGrammar
expect(editor.lineForScreenRow(0).tokens.length).toBe 1
@@ -2614,7 +2614,7 @@ describe "Editor", ->
expect(editor.shouldPromptToSave()).toBeFalsy()
buffer.setText('changed')
expect(editor.shouldPromptToSave()).toBeTruthy()
editor2 = project.openSync('sample.js', autoIndent: false)
editor2 = atom.project.openSync('sample.js', autoIndent: false)
expect(editor.shouldPromptToSave()).toBeFalsy()
editor2.destroy()
expect(editor.shouldPromptToSave()).toBeTruthy()

View File

@@ -12,7 +12,7 @@ describe "EditorView", ->
beforeEach ->
atom.packages.activatePackage('language-text', sync: true)
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
buffer = editor.buffer
editorView = new EditorView(editor)
editorView.lineOverdraw = 2
@@ -37,7 +37,7 @@ describe "EditorView", ->
cachedCharWidth
calcDimensions = ->
editorForMeasurement = new EditorView(editor: project.openSync('sample.js'))
editorForMeasurement = new EditorView(editor: atom.project.openSync('sample.js'))
editorForMeasurement.attachToDom()
cachedLineHeight = editorForMeasurement.lineHeight
cachedCharWidth = editorForMeasurement.charWidth
@@ -103,7 +103,7 @@ describe "EditorView", ->
it "triggers an alert", ->
filePath = path.join(temp.dir, 'atom-changed-file.txt')
fs.writeFileSync(filePath, "")
editor = project.openSync(filePath)
editor = atom.project.openSync(filePath)
editorView.edit(editor)
editorView.insertText("now the buffer is modified")
@@ -129,7 +129,7 @@ describe "EditorView", ->
[newEditSession, newBuffer] = []
beforeEach ->
newEditSession = project.openSync('two-hundred.txt')
newEditSession = atom.project.openSync('two-hundred.txt')
newBuffer = newEditSession.buffer
it "updates the rendered lines, cursors, selections, scroll position, and event subscriptions to match the given edit session", ->
@@ -168,7 +168,7 @@ describe "EditorView", ->
it "triggers alert if edit session's buffer goes into conflict with changes on disk", ->
filePath = path.join(temp.dir, 'atom-changed-file.txt')
fs.writeFileSync(filePath, "")
tempEditSession = project.openSync(filePath)
tempEditSession = atom.project.openSync(filePath)
editorView.edit(tempEditSession)
tempEditSession.insertText("a buffer change")
@@ -277,7 +277,7 @@ describe "EditorView", ->
it "emits event when editor view view receives a new buffer", ->
eventHandler = jasmine.createSpy('eventHandler')
editorView.on 'editor:path-changed', eventHandler
editorView.edit(project.openSync(filePath))
editorView.edit(atom.project.openSync(filePath))
expect(eventHandler).toHaveBeenCalled()
it "stops listening to events on previously set buffers", ->
@@ -285,7 +285,7 @@ describe "EditorView", ->
oldBuffer = editorView.getBuffer()
editorView.on 'editor:path-changed', eventHandler
editorView.edit(project.openSync(filePath))
editorView.edit(atom.project.openSync(filePath))
expect(eventHandler).toHaveBeenCalled()
eventHandler.reset()
@@ -1481,7 +1481,7 @@ describe "EditorView", ->
describe "when autoscrolling at the end of the document", ->
it "renders lines properly", ->
editorView.edit(project.openSync('two-hundred.txt'))
editorView.edit(atom.project.openSync('two-hundred.txt'))
editorView.attachToDom(heightInLines: 5.5)
expect(editorView.renderedLines.find('.line').length).toBe 8
@@ -1736,7 +1736,7 @@ describe "EditorView", ->
expect(editorView.bufferPositionForScreenPosition(editorView.getCursorScreenPosition())).toEqual [3, 60]
it "does not wrap the lines of any newly assigned buffers", ->
otherEditSession = project.openSync()
otherEditSession = atom.project.openSync()
otherEditSession.buffer.setText([1..100].join(''))
editorView.edit(otherEditSession)
expect(editorView.renderedLines.find('.line').length).toBe(1)
@@ -1768,7 +1768,7 @@ describe "EditorView", ->
expect(editorView.getCursorScreenPosition()).toEqual [11, 0]
it "calls .setWidthInChars() when the editor view is attached because now its dimensions are available to calculate it", ->
otherEditor = new EditorView(editor: project.openSync('sample.js'))
otherEditor = new EditorView(editor: atom.project.openSync('sample.js'))
spyOn(otherEditor, 'setWidthInChars')
otherEditor.activeEditSession.setSoftWrap(true)
@@ -1894,7 +1894,7 @@ describe "EditorView", ->
describe "when the switching from an edit session for a long buffer to an edit session for a short buffer", ->
it "updates the line numbers to reflect the shorter buffer", ->
emptyEditSession = project.openSync(null)
emptyEditSession = atom.project.openSync(null)
editorView.edit(emptyEditSession)
expect(editorView.gutter.lineNumbers.find('.line-number').length).toBe 1
@@ -2098,7 +2098,7 @@ describe "EditorView", ->
describe "folding", ->
beforeEach ->
editor = project.openSync('two-hundred.txt')
editor = atom.project.openSync('two-hundred.txt')
buffer = editor.buffer
editorView.edit(editor)
editorView.attachToDom()
@@ -2234,9 +2234,9 @@ describe "EditorView", ->
[filePath, originalPathText] = []
beforeEach ->
filePath = project.resolve('git/working-dir/file.txt')
filePath = atom.project.resolve('git/working-dir/file.txt')
originalPathText = fs.readFileSync(filePath, 'utf8')
editorView.edit(project.openSync(filePath))
editorView.edit(atom.project.openSync(filePath))
afterEach ->
fs.writeFileSync(filePath, originalPathText)
@@ -2369,7 +2369,7 @@ describe "EditorView", ->
fs.removeSync(filePath) if fs.existsSync(filePath)
it "updates all the rendered lines when the grammar changes", ->
editorView.edit(project.openSync(filePath))
editorView.edit(atom.project.openSync(filePath))
expect(editorView.getGrammar().name).toBe 'Plain Text'
atom.syntax.setGrammarOverrideForPath(filePath, 'source.js')
editorView.reloadGrammar()
@@ -2389,7 +2389,7 @@ describe "EditorView", ->
expect(editorView.getGrammar().name).toBe 'JavaScript'
it "emits an editor:grammar-changed event when updated", ->
editorView.edit(project.openSync(filePath))
editorView.edit(atom.project.openSync(filePath))
eventHandler = jasmine.createSpy('eventHandler')
editorView.on('editor:grammar-changed', eventHandler)
@@ -2740,10 +2740,10 @@ describe "EditorView", ->
describe "when the editor view is attached but invisible", ->
describe "when the editor view's text is changed", ->
it "redraws the editor view when it is next shown", ->
window.rootView = new RootView
rootView.openSync('sample.js')
rootView.attachToDom()
editorView = rootView.getActiveView()
atom.rootView = new RootView
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
view = $$ -> @div id: 'view', tabindex: -1, 'View'
editorView.getPane().showItem(view)
@@ -2794,10 +2794,10 @@ describe "EditorView", ->
describe "when the editor view is removed", ->
it "fires a editor:will-be-removed event", ->
window.rootView = new RootView
rootView.openSync('sample.js')
rootView.attachToDom()
editorView = rootView.getActiveView()
atom.rootView = new RootView
atom.rootView.openSync('sample.js')
atom.rootView.attachToDom()
editorView = atom.rootView.getActiveView()
willBeRemovedHandler = jasmine.createSpy('fileChange')
editorView.on 'editor:will-be-removed', willBeRemovedHandler

View File

@@ -9,5 +9,5 @@ module.exports =
activate: ->
@activateCallCount++
rootView.getActiveView()?.command 'activation-event', =>
atom.rootView.getActiveView()?.command 'activation-event', =>
@activationEventCallCount++

View File

@@ -182,10 +182,10 @@ describe "Git", ->
beforeEach ->
repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir'))
modifiedPath = project.resolve('git/working-dir/file.txt')
modifiedPath = atom.project.resolve('git/working-dir/file.txt')
originalModifiedPathText = fs.readFileSync(modifiedPath, 'utf8')
newPath = project.resolve('git/working-dir/untracked.txt')
cleanPath = project.resolve('git/working-dir/other.txt')
newPath = atom.project.resolve('git/working-dir/untracked.txt')
cleanPath = atom.project.resolve('git/working-dir/other.txt')
fs.writeFileSync(newPath, '')
afterEach ->
@@ -211,7 +211,7 @@ describe "Git", ->
[originalContent, editor] = []
beforeEach ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
originalContent = editor.getText()
afterEach ->
@@ -221,7 +221,7 @@ describe "Git", ->
editor.insertNewline()
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.save()
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@@ -230,7 +230,7 @@ describe "Git", ->
fs.writeFileSync(editor.getPath(), 'changed')
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.getBuffer().reload()
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@@ -241,7 +241,7 @@ describe "Git", ->
fs.writeFileSync(editor.getPath(), 'changed')
statusHandler = jasmine.createSpy('statusHandler')
project.getRepo().on 'status-changed', statusHandler
atom.project.getRepo().on 'status-changed', statusHandler
editor.getBuffer().emit 'path-changed'
expect(statusHandler.callCount).toBe 1
expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256
@@ -256,7 +256,7 @@ describe "Git", ->
project2?.destroy()
it "subscribes to all the serialized buffers in the project", ->
project.openSync('sample.js')
atom.project.openSync('sample.js')
#TODO Replace with atom.replicate().project when Atom is a telepath model
project2 = atom.replicate().get('project')
buffer = project2.getBuffers()[0]

View File

@@ -159,11 +159,11 @@ describe "Keymap", ->
describe "when the event's target is the document body", ->
it "triggers the mapped event on the rootView", ->
window.rootView = new RootView
rootView.attachToDom()
atom.rootView = new RootView
atom.rootView.attachToDom()
keymap.bindKeys 'name', 'body', 'x': 'foo'
fooHandler = jasmine.createSpy("fooHandler")
rootView.on 'foo', fooHandler
atom.rootView.on 'foo', fooHandler
result = keymap.handleKeyEvent(keydownEvent('x', target: document.body))
expect(result).toBe(false)

View File

@@ -7,7 +7,7 @@ describe "LanguageMode", ->
describe "javascript", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
{buffer, languageMode} = editor
describe ".minIndentLevelForRowRange(startRow, endRow)", ->
@@ -110,7 +110,7 @@ describe "LanguageMode", ->
describe "coffeescript", ->
beforeEach ->
atom.packages.activatePackage('language-coffee-script', sync: true)
editor = project.openSync('coffee.coffee', autoIndent: false)
editor = atom.project.openSync('coffee.coffee', autoIndent: false)
{buffer, languageMode} = editor
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@@ -157,7 +157,7 @@ describe "LanguageMode", ->
describe "css", ->
beforeEach ->
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('css.css', autoIndent: false)
editor = atom.project.openSync('css.css', autoIndent: false)
{buffer, languageMode} = editor
describe ".toggleLineCommentsForBufferRows(start, end)", ->
@@ -199,7 +199,7 @@ describe "LanguageMode", ->
beforeEach ->
atom.packages.activatePackage('language-less', sync: true)
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('sample.less', autoIndent: false)
editor = atom.project.openSync('sample.less', autoIndent: false)
{buffer, languageMode} = editor
describe "when commenting lines", ->
@@ -210,7 +210,7 @@ describe "LanguageMode", ->
describe "folding", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample.js', autoIndent: false)
editor = atom.project.openSync('sample.js', autoIndent: false)
{buffer, languageMode} = editor
it "maintains cursor buffer position when a folding/unfolding", ->
@@ -300,7 +300,7 @@ describe "LanguageMode", ->
describe "folding with comments", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
editor = project.openSync('sample-with-comments.js', autoIndent: false)
editor = atom.project.openSync('sample-with-comments.js', autoIndent: false)
{buffer, languageMode} = editor
describe ".unfoldAll()", ->
@@ -354,7 +354,7 @@ describe "LanguageMode", ->
beforeEach ->
atom.packages.activatePackage('language-source', sync: true)
atom.packages.activatePackage('language-css', sync: true)
editor = project.openSync('css.css', autoIndent: true)
editor = atom.project.openSync('css.css', autoIndent: true)
describe "suggestedIndentForBufferRow", ->
it "does not return negative values (regression)", ->

View File

@@ -111,7 +111,7 @@ describe "PaneContainer", ->
describe "when the last-closed pane item is an edit session", ->
it "reopens the edit session (regression)", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
pane3.showItem(editor)
pane3.destroyItem(editor)
expect(container.reopenItem()).toBeTruthy()

View File

@@ -20,8 +20,8 @@ describe "Pane", ->
container = new PaneContainer
view1 = new TestView(id: 'view-1', text: 'View 1')
view2 = new TestView(id: 'view-2', text: 'View 2')
editor1 = project.openSync('sample.js')
editor2 = project.openSync('sample.txt')
editor1 = atom.project.openSync('sample.js')
editor2 = atom.project.openSync('sample.txt')
pane = new Pane(view1, editor1, view2, editor2)
container.setRoot(pane)
@@ -475,20 +475,20 @@ describe "Pane", ->
describe "when it is the last pane", ->
beforeEach ->
expect(container.getPanes().length).toBe 1
window.rootView = focus: jasmine.createSpy("rootView.focus")
atom.rootView = focus: jasmine.createSpy("rootView.focus")
describe "when the removed pane is focused", ->
it "calls focus on rootView so we don't lose focus", ->
container.attachToDom()
pane.focus()
pane.remove()
expect(rootView.focus).toHaveBeenCalled()
expect(atom.rootView.focus).toHaveBeenCalled()
describe "when the removed pane is not focused", ->
it "does not call focus on root view", ->
expect(pane).not.toMatchSelector ':has(:focus)'
pane.remove()
expect(rootView.focus).not.toHaveBeenCalled()
expect(atom.rootView.focus).not.toHaveBeenCalled()
describe ".getNextPane()", ->
it "returns the next pane if one exists, wrapping around from the last pane to the first", ->
@@ -702,8 +702,8 @@ describe "Pane", ->
projectReplica = atom.replicate().get('project')
containerState = container.serialize()
container.remove()
project.destroy()
window.project = projectReplica
atom.project = projectReplica
atom.project.destroy()
container = atom.deserializers.deserialize(containerState)
pane = container.getRoot()
container.attachToDom()

View File

@@ -8,7 +8,7 @@ BufferedProcess = require '../src/buffered-process'
describe "Project", ->
beforeEach ->
project.setPath(project.resolve('dir'))
atom.project.setPath(atom.project.resolve('dir'))
describe "serialization", ->
deserializedProject = null
@@ -17,17 +17,19 @@ describe "Project", ->
deserializedProject?.destroy()
it "destroys unretained buffers and does not include them in the serialized state", ->
project.bufferForPathSync('a')
expect(project.getBuffers().length).toBe 1
project.getState().serializeForPersistence()
atom.project.bufferForPathSync('a')
expect(atom.project.getBuffers().length).toBe 1
atom.project.getState().serializeForPersistence()
deserializedProject = atom.replicate().get('project')
expect(deserializedProject.getBuffers().length).toBe 0
expect(project.getBuffers().length).toBe 0
expect(atom.project.getBuffers().length).toBe 0
it "listens for destroyed events on deserialized buffers and removes them when they are destroyed", ->
project.openSync('a')
expect(project.getBuffers().length).toBe 1
project.getState().serializeForPersistence()
atom.project.openSync('a')
expect(atom.project.getBuffers().length).toBe 1
atom.project.getState().serializeForPersistence()
deserializedProject = atom.replicate().get('project')
expect(deserializedProject.getBuffers().length).toBe 1
@@ -36,113 +38,113 @@ describe "Project", ->
describe "when an edit session is destroyed", ->
it "removes edit session and calls destroy on buffer (if buffer is not referenced by other edit sessions)", ->
editor = project.openSync("a")
anotherEditSession = project.openSync("a")
editor = atom.project.openSync("a")
anotherEditSession = atom.project.openSync("a")
expect(project.editors.length).toBe 2
expect(atom.project.editors.length).toBe 2
expect(editor.buffer).toBe anotherEditSession.buffer
editor.destroy()
expect(project.editors.length).toBe 1
expect(atom.project.editors.length).toBe 1
anotherEditSession.destroy()
expect(project.editors.length).toBe 0
expect(atom.project.editors.length).toBe 0
describe "when an edit session is saved and the project has no path", ->
it "sets the project's path to the saved file's parent directory", ->
tempFile = temp.openSync().path
project.setPath(undefined)
expect(project.getPath()).toBeUndefined()
editor = project.openSync()
atom.project.setPath(undefined)
expect(atom.project.getPath()).toBeUndefined()
editor = atom.project.openSync()
editor.saveAs(tempFile)
expect(project.getPath()).toBe path.dirname(tempFile)
expect(atom.project.getPath()).toBe path.dirname(tempFile)
describe "when an edit session is deserialized", ->
it "emits an 'editor-created' event and stores the edit session", ->
handler = jasmine.createSpy('editorCreatedHandler')
project.on 'editor-created', handler
atom.project.on 'editor-created', handler
editor1 = project.openSync("a")
editor1 = atom.project.openSync("a")
expect(handler.callCount).toBe 1
expect(project.getEditSessions().length).toBe 1
expect(project.getEditSessions()[0]).toBe editor1
expect(atom.project.getEditSessions().length).toBe 1
expect(atom.project.getEditSessions()[0]).toBe editor1
editor2 = atom.deserializers.deserialize(editor1.serialize())
expect(handler.callCount).toBe 2
expect(project.getEditSessions().length).toBe 2
expect(project.getEditSessions()[0]).toBe editor1
expect(project.getEditSessions()[1]).toBe editor2
expect(atom.project.getEditSessions().length).toBe 2
expect(atom.project.getEditSessions()[0]).toBe editor1
expect(atom.project.getEditSessions()[1]).toBe editor2
describe "when an edit session is copied", ->
it "emits an 'editor-created' event and stores the edit session", ->
handler = jasmine.createSpy('editorCreatedHandler')
project.on 'editor-created', handler
atom.project.on 'editor-created', handler
editor1 = project.openSync("a")
editor1 = atom.project.openSync("a")
expect(handler.callCount).toBe 1
expect(project.getEditSessions().length).toBe 1
expect(project.getEditSessions()[0]).toBe editor1
expect(atom.project.getEditSessions().length).toBe 1
expect(atom.project.getEditSessions()[0]).toBe editor1
editor2 = editor1.copy()
expect(handler.callCount).toBe 2
expect(project.getEditSessions().length).toBe 2
expect(project.getEditSessions()[0]).toBe editor1
expect(project.getEditSessions()[1]).toBe editor2
expect(atom.project.getEditSessions().length).toBe 2
expect(atom.project.getEditSessions()[0]).toBe editor1
expect(atom.project.getEditSessions()[1]).toBe editor2
describe ".openSync(path)", ->
[fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = []
beforeEach ->
absolutePath = require.resolve('./fixtures/dir/a')
newBufferHandler = jasmine.createSpy('newBufferHandler')
project.on 'buffer-created', newBufferHandler
atom.project.on 'buffer-created', newBufferHandler
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
project.on 'editor-created', newEditSessionHandler
atom.project.on 'editor-created', newEditSessionHandler
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
project.registerOpener(fooOpener)
project.registerOpener(barOpener)
atom.project.registerOpener(fooOpener)
atom.project.registerOpener(barOpener)
afterEach ->
project.unregisterOpener(fooOpener)
project.unregisterOpener(barOpener)
atom.project.unregisterOpener(fooOpener)
atom.project.unregisterOpener(barOpener)
describe "when passed a path that doesn't match a custom opener", ->
describe "when given an absolute path that hasn't been opened previously", ->
it "returns a new edit session for the given path and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync(absolutePath)
editor = atom.project.openSync(absolutePath)
expect(editor.buffer.getPath()).toBe absolutePath
expect(newBufferHandler).toHaveBeenCalledWith editor.buffer
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when given a relative path that hasn't been opened previously", ->
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync('a')
editor = atom.project.openSync('a')
expect(editor.buffer.getPath()).toBe absolutePath
expect(newBufferHandler).toHaveBeenCalledWith editor.buffer
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when passed the path to a buffer that has already been opened", ->
it "returns a new edit session containing previously opened buffer and emits a 'editor-created' event", ->
editor = project.openSync(absolutePath)
editor = atom.project.openSync(absolutePath)
newBufferHandler.reset()
expect(project.openSync(absolutePath).buffer).toBe editor.buffer
expect(project.openSync('a').buffer).toBe editor.buffer
expect(atom.project.openSync(absolutePath).buffer).toBe editor.buffer
expect(atom.project.openSync('a').buffer).toBe editor.buffer
expect(newBufferHandler).not.toHaveBeenCalled()
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when not passed a path", ->
it "returns a new edit session and emits 'buffer-created' and 'editor-created' events", ->
editor = project.openSync()
editor = atom.project.openSync()
expect(editor.buffer.getPath()).toBeUndefined()
expect(newBufferHandler).toHaveBeenCalledWith(editor.buffer)
expect(newEditSessionHandler).toHaveBeenCalledWith editor
describe "when passed a path that matches a custom opener", ->
it "returns the resource returned by the custom opener", ->
pathToOpen = project.resolve('a.foo')
expect(project.openSync(pathToOpen, hey: "there")).toEqual { foo: pathToOpen, options: {hey: "there"} }
expect(project.openSync("bar://baz")).toEqual { bar: "bar://baz" }
pathToOpen = atom.project.resolve('a.foo')
expect(atom.project.openSync(pathToOpen, hey: "there")).toEqual { foo: pathToOpen, options: {hey: "there"} }
expect(atom.project.openSync("bar://baz")).toEqual { bar: "bar://baz" }
describe ".open(path)", ->
[fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = []
@@ -150,25 +152,25 @@ describe "Project", ->
beforeEach ->
absolutePath = require.resolve('./fixtures/dir/a')
newBufferHandler = jasmine.createSpy('newBufferHandler')
project.on 'buffer-created', newBufferHandler
atom.project.on 'buffer-created', newBufferHandler
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
project.on 'editor-created', newEditSessionHandler
atom.project.on 'editor-created', newEditSessionHandler
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
project.registerOpener(fooOpener)
project.registerOpener(barOpener)
atom.project.registerOpener(fooOpener)
atom.project.registerOpener(barOpener)
afterEach ->
project.unregisterOpener(fooOpener)
project.unregisterOpener(barOpener)
atom.project.unregisterOpener(fooOpener)
atom.project.unregisterOpener(barOpener)
describe "when passed a path that doesn't match a custom opener", ->
describe "when given an absolute path that isn't currently open", ->
it "returns a new edit session for the given path and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBe absolutePath
@@ -179,7 +181,7 @@ describe "Project", ->
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBe absolutePath
@@ -190,12 +192,12 @@ describe "Project", ->
it "returns a new edit session containing currently opened buffer and emits a 'editor-created' event", ->
editor = null
waitsForPromise ->
project.open(absolutePath).then (o) -> editor = o
atom.project.open(absolutePath).then (o) -> editor = o
runs ->
newBufferHandler.reset()
expect(project.openSync(absolutePath).buffer).toBe editor.buffer
expect(project.openSync('a').buffer).toBe editor.buffer
expect(atom.project.openSync(absolutePath).buffer).toBe editor.buffer
expect(atom.project.openSync('a').buffer).toBe editor.buffer
expect(newBufferHandler).not.toHaveBeenCalled()
expect(newEditSessionHandler).toHaveBeenCalledWith editor
@@ -203,7 +205,7 @@ describe "Project", ->
it "returns a new edit session and emits 'buffer-created' and 'editor-created' events", ->
editor = null
waitsForPromise ->
project.open().then (o) -> editor = o
atom.project.open().then (o) -> editor = o
runs ->
expect(editor.buffer.getPath()).toBeUndefined()
@@ -213,18 +215,18 @@ describe "Project", ->
describe "when passed a path that matches a custom opener", ->
it "returns the resource returned by the custom opener", ->
waitsForPromise ->
pathToOpen = project.resolve('a.foo')
project.open(pathToOpen, hey: "there").then (item) ->
pathToOpen = atom.project.resolve('a.foo')
atom.project.open(pathToOpen, hey: "there").then (item) ->
expect(item).toEqual { foo: pathToOpen, options: {hey: "there"} }
waitsForPromise ->
project.open("bar://baz").then (item) ->
atom.project.open("bar://baz").then (item) ->
expect(item).toEqual { bar: "bar://baz" }
it "returns number of read bytes as progress indicator", ->
filePath = project.resolve 'a'
filePath = atom.project.resolve 'a'
totalBytes = 0
promise = project.open(filePath)
promise = atom.project.open(filePath)
promise.progress (bytesRead) -> totalBytes = bytesRead
waitsForPromise ->
@@ -236,22 +238,22 @@ describe "Project", ->
describe ".bufferForPathSync(path)", ->
describe "when opening a previously opened path", ->
it "does not create a new buffer", ->
buffer = project.bufferForPathSync("a").retain()
expect(project.bufferForPathSync("a")).toBe buffer
buffer = atom.project.bufferForPathSync("a").retain()
expect(atom.project.bufferForPathSync("a")).toBe buffer
alternativeBuffer = project.bufferForPathSync("b").retain().release()
alternativeBuffer = atom.project.bufferForPathSync("b").retain().release()
expect(alternativeBuffer).not.toBe buffer
buffer.release()
it "creates a new buffer if the previous buffer was destroyed", ->
buffer = project.bufferForPathSync("a").retain().release()
expect(project.bufferForPathSync("a").retain().release()).not.toBe buffer
buffer = atom.project.bufferForPathSync("a").retain().release()
expect(atom.project.bufferForPathSync("a").retain().release()).not.toBe buffer
describe ".bufferForPath(path)", ->
[buffer] = []
beforeEach ->
waitsForPromise ->
project.bufferForPath("a").then (o) ->
atom.project.bufferForPath("a").then (o) ->
buffer = o
buffer.retain()
@@ -261,60 +263,60 @@ describe "Project", ->
describe "when opening a previously opened path", ->
it "does not create a new buffer", ->
waitsForPromise ->
project.bufferForPath("a").then (anotherBuffer) ->
atom.project.bufferForPath("a").then (anotherBuffer) ->
expect(anotherBuffer).toBe buffer
waitsForPromise ->
project.bufferForPath("b").then (anotherBuffer) ->
atom.project.bufferForPath("b").then (anotherBuffer) ->
expect(anotherBuffer).not.toBe buffer
it "creates a new buffer if the previous buffer was destroyed", ->
buffer.release()
waitsForPromise ->
project.bufferForPath("b").then (anotherBuffer) ->
atom.project.bufferForPath("b").then (anotherBuffer) ->
expect(anotherBuffer).not.toBe buffer
describe ".resolve(uri)", ->
describe "when passed an absolute or relative path", ->
it "returns an absolute path based on the project's root", ->
it "returns an absolute path based on the atom.project's root", ->
absolutePath = require.resolve('./fixtures/dir/a')
expect(project.resolve('a')).toBe absolutePath
expect(project.resolve(absolutePath + '/../a')).toBe absolutePath
expect(project.resolve('a/../a')).toBe absolutePath
expect(atom.project.resolve('a')).toBe absolutePath
expect(atom.project.resolve(absolutePath + '/../a')).toBe absolutePath
expect(atom.project.resolve('a/../a')).toBe absolutePath
describe "when passed a uri with a scheme", ->
it "does not modify uris that begin with a scheme", ->
expect(project.resolve('http://zombo.com')).toBe 'http://zombo.com'
expect(atom.project.resolve('http://zombo.com')).toBe 'http://zombo.com'
describe ".setPath(path)", ->
describe "when path is a file", ->
it "sets its path to the files parent directory and updates the root directory", ->
project.setPath(require.resolve('./fixtures/dir/a'))
expect(project.getPath()).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
expect(project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
atom.project.setPath(require.resolve('./fixtures/dir/a'))
expect(atom.project.getPath()).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
expect(atom.project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
describe "when path is a directory", ->
it "sets its path to the directory and updates the root directory", ->
directory = fs.absolute(path.join(__dirname, 'fixtures', 'dir', 'a-dir'))
project.setPath(directory)
expect(project.getPath()).toEqual directory
expect(project.getRootDirectory().path).toEqual directory
atom.project.setPath(directory)
expect(atom.project.getPath()).toEqual directory
expect(atom.project.getRootDirectory().path).toEqual directory
describe "when path is null", ->
it "sets its path and root directory to null", ->
project.setPath(null)
expect(project.getPath()?).toBeFalsy()
expect(project.getRootDirectory()?).toBeFalsy()
atom.project.setPath(null)
expect(atom.project.getPath()?).toBeFalsy()
expect(atom.project.getRootDirectory()?).toBeFalsy()
describe ".replace()", ->
[filePath, commentFilePath, sampleContent, sampleCommentContent] = []
beforeEach ->
project.setPath(project.resolve('../'))
atom.project.setPath(atom.project.resolve('../'))
filePath = project.resolve('sample.js')
commentFilePath = project.resolve('sample-with-comments.js')
filePath = atom.project.resolve('sample.js')
commentFilePath = atom.project.resolve('sample-with-comments.js')
sampleContent = fs.readFileSync(filePath).toString()
sampleCommentContent = fs.readFileSync(commentFilePath).toString()
@@ -326,7 +328,7 @@ describe "Project", ->
it "replaces properly", ->
results = []
waitsForPromise ->
project.replace /items/gi, 'items', [filePath], (result) ->
atom.project.replace /items/gi, 'items', [filePath], (result) ->
results.push(result)
runs ->
@@ -336,12 +338,12 @@ describe "Project", ->
describe "when a buffer is already open", ->
it "replaces properly and saves when not modified", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
expect(editor.isModified()).toBeFalsy()
results = []
waitsForPromise ->
project.replace /items/gi, 'items', [filePath], (result) ->
atom.project.replace /items/gi, 'items', [filePath], (result) ->
results.push(result)
runs ->
@@ -352,13 +354,13 @@ describe "Project", ->
expect(editor.isModified()).toBeFalsy()
it "does NOT save when modified", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.buffer.change([[0,0],[0,0]], 'omg')
expect(editor.isModified()).toBeTruthy()
results = []
waitsForPromise ->
project.replace /items/gi, 'okthen', [filePath], (result) ->
atom.project.replace /items/gi, 'okthen', [filePath], (result) ->
results.push(result)
runs ->
@@ -373,12 +375,12 @@ describe "Project", ->
it "calls the callback with all regex results in all files in the project", ->
results = []
waitsForPromise ->
project.scan /(a)+/, (result) ->
atom.project.scan /(a)+/, (result) ->
results.push(result)
runs ->
expect(results).toHaveLength(3)
expect(results[0].filePath).toBe project.resolve('a')
expect(results[0].filePath).toBe atom.project.resolve('a')
expect(results[0].matches).toHaveLength(3)
expect(results[0].matches[0]).toEqual
matchText: 'aaa'
@@ -389,13 +391,13 @@ describe "Project", ->
it "works with with escaped literals (like $ and ^)", ->
results = []
waitsForPromise ->
project.scan /\$\w+/, (result) -> results.push(result)
atom.project.scan /\$\w+/, (result) -> results.push(result)
runs ->
expect(results.length).toBe 1
{filePath, matches} = results[0]
expect(filePath).toBe project.resolve('a')
expect(filePath).toBe atom.project.resolve('a')
expect(matches).toHaveLength 1
expect(matches[0]).toEqual
matchText: '$bill'
@@ -404,11 +406,11 @@ describe "Project", ->
range: [[2, 6], [2, 11]]
it "works on evil filenames", ->
project.setPath(path.join(__dirname, 'fixtures', 'evil-files'))
atom.project.setPath(path.join(__dirname, 'fixtures', 'evil-files'))
paths = []
matches = []
waitsForPromise ->
project.scan /evil/, (result) ->
atom.project.scan /evil/, (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@@ -431,7 +433,7 @@ describe "Project", ->
it "ignores case if the regex includes the `i` flag", ->
results = []
waitsForPromise ->
project.scan /DOLLAR/i, (result) -> results.push(result)
atom.project.scan /DOLLAR/i, (result) -> results.push(result)
runs ->
expect(results).toHaveLength 1
@@ -459,11 +461,11 @@ describe "Project", ->
fs.removeSync(projectPath) if fs.existsSync(projectPath)
it "excludes ignored files", ->
project.setPath(projectPath)
atom.project.setPath(projectPath)
atom.config.set('core.excludeVcsIgnoredPaths', true)
resultHandler = jasmine.createSpy("result found")
waitsForPromise ->
project.scan /match/, (results) ->
atom.project.scan /match/, (results) ->
resultHandler()
runs ->
@@ -471,14 +473,14 @@ describe "Project", ->
it "includes only files when a directory filter is specified", ->
projectPath = path.join(path.join(__dirname, 'fixtures', 'dir'))
project.setPath(projectPath)
atom.project.setPath(projectPath)
filePath = path.join(projectPath, 'a-dir', 'oh-git')
paths = []
matches = []
waitsForPromise ->
project.scan /aaa/, paths: ["a-dir#{path.sep}"], (result) ->
atom.project.scan /aaa/, paths: ["a-dir#{path.sep}"], (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@@ -491,11 +493,11 @@ describe "Project", ->
projectPath = temp.mkdirSync()
filePath = path.join(projectPath, '.text')
fs.writeFileSync(filePath, 'match this')
project.setPath(projectPath)
atom.project.setPath(projectPath)
paths = []
matches = []
waitsForPromise ->
project.scan /match this/, (result) ->
atom.project.scan /match this/, (result) ->
paths.push(result.filePath)
matches = matches.concat(result.matches)
@@ -512,18 +514,18 @@ describe "Project", ->
resultHandler = jasmine.createSpy("result found")
waitsForPromise ->
project.scan /dollar/, (results) ->
atom.project.scan /dollar/, (results) ->
resultHandler()
runs ->
expect(resultHandler).not.toHaveBeenCalled()
it "scans buffer contents if the buffer is modified", ->
editor = project.openSync("a")
editor = atom.project.openSync("a")
editor.setText("Elephant")
results = []
waitsForPromise ->
project.scan /a|Elephant/, (result) -> results.push result
atom.project.scan /a|Elephant/, (result) -> results.push result
runs ->
expect(results).toHaveLength 3

View File

@@ -8,68 +8,68 @@ describe "RootView", ->
pathToOpen = null
beforeEach ->
project.setPath(project.resolve('dir'))
pathToOpen = project.resolve('a')
window.rootView = new RootView
rootView.enableKeymap()
rootView.openSync(pathToOpen)
rootView.focus()
atom.project.setPath(atom.project.resolve('dir'))
pathToOpen = atom.project.resolve('a')
atom.rootView = new RootView
atom.rootView.enableKeymap()
atom.rootView.openSync(pathToOpen)
atom.rootView.focus()
describe "@deserialize()", ->
viewState = null
refreshRootViewAndProject = ->
rootViewState = rootView.serialize()
project.getState().serializeForPersistence()
rootViewState = atom.rootView.serialize()
atom.project.getState().serializeForPersistence()
project2 = atom.replicate().get('project')
rootView.remove()
project.destroy()
window.project = project2
window.rootView = atom.deserializers.deserialize(rootViewState)
rootView.attachToDom()
atom.rootView.remove()
atom.project.destroy()
atom.project = project2
atom.rootView = atom.deserializers.deserialize(rootViewState)
atom.rootView.attachToDom()
describe "when the serialized RootView has an unsaved buffer", ->
it "constructs the view with the same panes", ->
rootView.attachToDom()
rootView.openSync()
editor1 = rootView.getActiveView()
atom.rootView.attachToDom()
atom.rootView.openSync()
editor1 = atom.rootView.getActiveView()
buffer = editor1.getBuffer()
editor1.splitRight()
expect(rootView.getActiveView()).toBe rootView.getEditors()[2]
expect(atom.rootView.getActiveView()).toBe atom.rootView.getEditors()[2]
refreshRootViewAndProject()
expect(rootView.getEditors().length).toBe 2
expect(rootView.getActiveView()).toBe rootView.getEditors()[1]
expect(rootView.title).toBe "untitled - #{project.getPath()}"
expect(atom.rootView.getEditors().length).toBe 2
expect(atom.rootView.getActiveView()).toBe atom.rootView.getEditors()[1]
expect(atom.rootView.title).toBe "untitled - #{atom.project.getPath()}"
describe "when there are open editors", ->
it "constructs the view with the same panes", ->
rootView.attachToDom()
pane1 = rootView.getActivePane()
atom.rootView.attachToDom()
pane1 = atom.rootView.getActivePane()
pane2 = pane1.splitRight()
pane3 = pane2.splitRight()
pane4 = pane2.splitDown()
pane2.showItem(project.openSync('b'))
pane3.showItem(project.openSync('../sample.js'))
pane2.showItem(atom.project.openSync('b'))
pane3.showItem(atom.project.openSync('../sample.js'))
pane3.activeItem.setCursorScreenPosition([2, 4])
pane4.showItem(project.openSync('../sample.txt'))
pane4.showItem(atom.project.openSync('../sample.txt'))
pane4.activeItem.setCursorScreenPosition([0, 2])
pane2.focus()
refreshRootViewAndProject()
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()
editor4 = rootView.panes.find('.row > .column > .pane .editor:eq(1)').view()
expect(atom.rootView.getEditors().length).toBe 4
editor1 = atom.rootView.panes.find('.row > .pane .editor:eq(0)').view()
editor3 = atom.rootView.panes.find('.row > .pane .editor:eq(1)').view()
editor2 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(0)').view()
editor4 = atom.rootView.panes.find('.row > .column > .pane .editor:eq(1)').view()
expect(editor1.getPath()).toBe project.resolve('a')
expect(editor2.getPath()).toBe project.resolve('b')
expect(editor3.getPath()).toBe project.resolve('../sample.js')
expect(editor1.getPath()).toBe atom.project.resolve('a')
expect(editor2.getPath()).toBe atom.project.resolve('b')
expect(editor3.getPath()).toBe atom.project.resolve('../sample.js')
expect(editor3.getCursorScreenPosition()).toEqual [2, 4]
expect(editor4.getPath()).toBe project.resolve('../sample.txt')
expect(editor4.getPath()).toBe atom.project.resolve('../sample.txt')
expect(editor4.getCursorScreenPosition()).toEqual [0, 2]
# ensure adjust pane dimensions is called
@@ -84,181 +84,181 @@ describe "RootView", ->
expect(editor3.isFocused).toBeFalsy()
expect(editor4.isFocused).toBeFalsy()
expect(rootView.title).toBe "#{path.basename(editor2.getPath())} - #{project.getPath()}"
expect(atom.rootView.title).toBe "#{path.basename(editor2.getPath())} - #{atom.project.getPath()}"
describe "where there are no open editors", ->
it "constructs the view with no open editors", ->
rootView.getActivePane().remove()
expect(rootView.getEditors().length).toBe 0
atom.rootView.getActivePane().remove()
expect(atom.rootView.getEditors().length).toBe 0
refreshRootViewAndProject()
expect(rootView.getEditors().length).toBe 0
expect(atom.rootView.getEditors().length).toBe 0
describe "focus", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
describe "when there is an active view", ->
it "hands off focus to the active view", ->
editorView = rootView.getActiveView()
editorView = atom.rootView.getActiveView()
editorView.isFocused = false
rootView.focus()
atom.rootView.focus()
expect(editorView.isFocused).toBeTruthy()
describe "when there is no active view", ->
beforeEach ->
rootView.getActivePane().remove()
expect(rootView.getActiveView()).toBeUndefined()
rootView.attachToDom()
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActiveView()).toBeUndefined()
atom.rootView.attachToDom()
expect(document.activeElement).toBe document.body
describe "when are visible focusable elements (with a -1 tabindex)", ->
it "passes focus to the first focusable element", ->
focusable1 = $$ -> @div "One", id: 'one', tabindex: -1
focusable2 = $$ -> @div "Two", id: 'two', tabindex: -1
rootView.horizontal.append(focusable1, focusable2)
atom.rootView.horizontal.append(focusable1, focusable2)
expect(document.activeElement).toBe document.body
rootView.focus()
atom.rootView.focus()
expect(document.activeElement).toBe focusable1[0]
describe "when there are no visible focusable elements", ->
it "surrenders focus to the body", ->
focusable = $$ -> @div "One", id: 'one', tabindex: -1
rootView.horizontal.append(focusable)
atom.rootView.horizontal.append(focusable)
focusable.hide()
expect(document.activeElement).toBe document.body
rootView.focus()
atom.rootView.focus()
expect(document.activeElement).toBe document.body
describe "keymap wiring", ->
commandHandler = null
beforeEach ->
commandHandler = jasmine.createSpy('commandHandler')
rootView.on('foo-command', commandHandler)
atom.rootView.on('foo-command', commandHandler)
atom.keymap.bindKeys('name', '*', 'x': 'foo-command')
describe "when a keydown event is triggered in the RootView", ->
it "triggers matching keybindings for that event", ->
event = keydownEvent 'x', target: rootView[0]
event = keydownEvent 'x', target: atom.rootView[0]
rootView.trigger(event)
atom.rootView.trigger(event)
expect(commandHandler).toHaveBeenCalled()
describe "window title", ->
describe "when the project has no path", ->
it "sets the title to 'untitled'", ->
project.setPath(undefined)
expect(rootView.title).toBe 'untitled'
atom.project.setPath(undefined)
expect(atom.rootView.title).toBe 'untitled'
describe "when the project has a path", ->
beforeEach ->
rootView.openSync('b')
atom.rootView.openSync('b')
describe "when there is an active pane item", ->
it "sets the title to the pane item's title plus the project path", ->
item = rootView.getActivePaneItem()
expect(rootView.title).toBe "#{item.getTitle()} - #{project.getPath()}"
item = atom.rootView.getActivePaneItem()
expect(atom.rootView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
describe "when the title of the active pane item changes", ->
it "updates the window title based on the item's new title", ->
editor = rootView.getActivePaneItem()
editor = atom.rootView.getActivePaneItem()
editor.buffer.setPath(path.join(temp.dir, 'hi'))
expect(rootView.title).toBe "#{editor.getTitle()} - #{project.getPath()}"
expect(atom.rootView.title).toBe "#{editor.getTitle()} - #{atom.project.getPath()}"
describe "when the active pane's item changes", ->
it "updates the title to the new item's title plus the project path", ->
rootView.getActivePane().showNextItem()
item = rootView.getActivePaneItem()
expect(rootView.title).toBe "#{item.getTitle()} - #{project.getPath()}"
atom.rootView.getActivePane().showNextItem()
item = atom.rootView.getActivePaneItem()
expect(atom.rootView.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
describe "when the last pane item is removed", ->
it "updates the title to contain the project's path", ->
rootView.getActivePane().remove()
expect(rootView.getActivePaneItem()).toBeUndefined()
expect(rootView.title).toBe project.getPath()
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePaneItem()).toBeUndefined()
expect(atom.rootView.title).toBe atom.project.getPath()
describe "when an inactive pane's item changes", ->
it "does not update the title", ->
pane = rootView.getActivePane()
pane = atom.rootView.getActivePane()
pane.splitRight()
initialTitle = rootView.title
initialTitle = atom.rootView.title
pane.showNextItem()
expect(rootView.title).toBe initialTitle
expect(atom.rootView.title).toBe initialTitle
describe "when the root view is deserialized", ->
it "updates the title to contain the project's path", ->
rootView2 = atom.deserializers.deserialize(rootView.serialize())
item = rootView.getActivePaneItem()
expect(rootView2.title).toBe "#{item.getTitle()} - #{project.getPath()}"
rootView2 = atom.deserializers.deserialize(atom.rootView.serialize())
item = atom.rootView.getActivePaneItem()
expect(rootView2.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
rootView2.remove()
describe "font size adjustment", ->
it "increases/decreases font size when increase/decrease-font-size events are triggered", ->
fontSizeBefore = atom.config.get('editor.fontSize')
rootView.trigger 'window:increase-font-size'
atom.rootView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
rootView.trigger 'window:increase-font-size'
atom.rootView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 2
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore
it "does not allow the font size to be less than 1", ->
atom.config.set("editor.fontSize", 1)
rootView.trigger 'window:decrease-font-size'
atom.rootView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe 1
describe ".openSync(filePath, options)", ->
describe "when there is no active pane", ->
beforeEach ->
spyOn(Pane.prototype, 'focus')
rootView.getActivePane().remove()
expect(rootView.getActivePane()).toBeUndefined()
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
editor = rootView.openSync()
expect(rootView.getActivePane().activeItem).toBe editor
editor = atom.rootView.openSync()
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
expect(rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
it "can create multiple empty edit sessions as an item on a new pane", ->
editor = rootView.openSync()
editor2 = rootView.openSync()
expect(rootView.getActivePane().getItems().length).toBe 2
editor = atom.rootView.openSync()
editor2 = atom.rootView.openSync()
expect(atom.rootView.getActivePane().getItems().length).toBe 2
expect(editor).not.toBe editor2
describe "when called with a path", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = rootView.openSync('b')
expect(rootView.getActivePane().activeItem).toBe editor
editor = atom.rootView.openSync('b')
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the new pane", ->
editor = rootView.openSync('b', changeFocus: false)
expect(rootView.getActivePane().focus).not.toHaveBeenCalled()
editor = atom.rootView.openSync('b', changeFocus: false)
expect(atom.rootView.getActivePane().focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
editor = rootView.openSync('b', split: 'right')
expect(rootView.getActivePane().activeItem).toBe editor
editor = atom.rootView.openSync('b', split: 'right')
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
describe "when there is an active pane", ->
[activePane, initialItemCount] = []
beforeEach ->
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
spyOn(activePane, 'focus')
initialItemCount = activePane.getItems().length
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = rootView.openSync()
editor = atom.rootView.openSync()
expect(activePane.getItems().length).toBe initialItemCount + 1
expect(activePane.activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
@@ -269,11 +269,11 @@ describe "RootView", ->
it "shows the existing edit session in the pane", ->
previousEditSession = activePane.activeItem
editor = rootView.openSync('b')
editor = atom.rootView.openSync('b')
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
editor = rootView.openSync(previousEditSession.getPath())
editor = atom.rootView.openSync(previousEditSession.getPath())
expect(editor).toBe previousEditSession
expect(activePane.activeItem).toBe editor
@@ -281,85 +281,85 @@ describe "RootView", ->
describe "when the active pane does not have an edit session item for the path being opened", ->
it "creates a new edit session for the given path in the active editor", ->
editor = rootView.openSync('b')
editor = atom.rootView.openSync('b')
expect(activePane.items.length).toBe 2
expect(activePane.activeItem).toBe editor
expect(activePane.focus).toHaveBeenCalled()
describe "when the changeFocus option is false", ->
it "does not focus the active pane", ->
editor = rootView.openSync('b', changeFocus: false)
editor = atom.rootView.openSync('b', changeFocus: false)
expect(activePane.focus).not.toHaveBeenCalled()
describe "when the split option is 'right'", ->
it "creates a new pane and opens the file in said pane", ->
pane1 = rootView.getActivePane()
pane1 = atom.rootView.getActivePane()
editor = rootView.openSync('b', split: 'right')
pane2 = rootView.getActivePane()
editor = atom.rootView.openSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
editor = rootView.openSync('file1', split: 'right')
pane3 = rootView.getActivePane()
editor = atom.rootView.openSync('file1', split: 'right')
pane3 = atom.rootView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/file1')
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
describe ".openSingletonSync(filePath, options)", ->
describe "when there is an active pane", ->
[pane1] = []
beforeEach ->
spyOn(Pane.prototype, 'focus').andCallFake -> @makeActive()
pane1 = rootView.getActivePane()
pane1 = atom.rootView.getActivePane()
it "creates a new pane and reuses the file when already open", ->
rootView.openSingletonSync('b', split: 'right')
pane2 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
pane1.focus()
expect(rootView.getActivePane()[0]).toBe pane1[0]
expect(atom.rootView.getActivePane()[0]).toBe pane1[0]
rootView.openSingletonSync('b', split: 'right')
pane3 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane3 = atom.rootView.getActivePane()
expect(pane3[0]).toBe pane2[0]
expect(pane1.itemForUri('b')).toBeFalsy()
expect(pane2.itemForUri('b')).not.toBeFalsy()
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "handles split: left by opening to the left pane when necessary", ->
rootView.openSingletonSync('b', split: 'right')
pane2 = rootView.getActivePane()
atom.rootView.openSingletonSync('b', split: 'right')
pane2 = atom.rootView.getActivePane()
expect(pane2[0]).not.toBe pane1[0]
rootView.openSingletonSync('file1', split: 'left')
atom.rootView.openSingletonSync('file1', split: 'left')
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(pane1.itemForUri('file1')).toBeTruthy()
expect(pane2.itemForUri('file1')).toBeFalsy()
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
pane2.focus()
expect(rootView.getActivePane()[0]).toBe pane2[0]
expect(atom.rootView.getActivePane()[0]).toBe pane2[0]
rootView.openSingletonSync('file1', split: 'left')
activePane = rootView.getActivePane()
atom.rootView.openSingletonSync('file1', split: 'left')
activePane = atom.rootView.getActivePane()
expect(activePane[0]).toBe pane1[0]
expect(rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
expect(atom.rootView.panes.find('.row .pane').toArray()).toEqual [pane1[0], pane2[0]]
it "reuses the file when already open", ->
rootView.openSync('b')
rootView.openSingletonSync('b', split: 'right')
expect(rootView.panes.find('.pane').toArray()).toEqual [pane1[0]]
atom.rootView.openSync('b')
atom.rootView.openSingletonSync('b', split: 'right')
expect(atom.rootView.panes.find('.pane').toArray()).toEqual [pane1[0]]
describe ".open(filePath)", ->
beforeEach ->
@@ -367,60 +367,60 @@ describe "RootView", ->
describe "when there is no active pane", ->
beforeEach ->
rootView.getActivePane().remove()
expect(rootView.getActivePane()).toBeUndefined()
atom.rootView.getActivePane().remove()
expect(atom.rootView.getActivePane()).toBeUndefined()
describe "when called with no path", ->
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
editor = null
waitsForPromise ->
rootView.open().then (o) -> editor = o
atom.rootView.open().then (o) -> editor = o
runs ->
expect(rootView.getActivePane().activeItem).toBe editor
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBeUndefined()
expect(rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
it "can create multiple empty edit sessions as items on a pane", ->
editor1 = null
editor2 = null
waitsForPromise ->
rootView.open()
atom.rootView.open()
.then (o) ->
editor1 = o
rootView.open()
atom.rootView.open()
.then (o) ->
editor2 = o
runs ->
expect(rootView.getActivePane().getItems().length).toBe 2
expect(atom.rootView.getActivePane().getItems().length).toBe 2
expect(editor1).not.toBe editor2
describe "when called with a path", ->
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(rootView.getActivePane().activeItem).toBe editor
expect(atom.rootView.getActivePane().activeItem).toBe editor
expect(editor.getPath()).toBe require.resolve('./fixtures/dir/b')
expect(rootView.getActivePane().focus).toHaveBeenCalled()
expect(atom.rootView.getActivePane().focus).toHaveBeenCalled()
describe "when there is an active pane", ->
[activePane] = []
beforeEach ->
activePane = rootView.getActivePane()
activePane = atom.rootView.getActivePane()
describe "when called with no path", ->
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
editor = null
waitsForPromise ->
rootView.open().then (o) -> editor = o
atom.rootView.open().then (o) -> editor = o
runs ->
expect(activePane.getItems().length).toBe 2
@@ -435,14 +435,14 @@ describe "RootView", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
expect(editor).not.toBe previousEditSession
waitsForPromise ->
rootView.open(previousEditSession.getPath()).then (o) -> editor = o
atom.rootView.open(previousEditSession.getPath()).then (o) -> editor = o
runs ->
expect(editor).toBe previousEditSession
@@ -454,7 +454,7 @@ describe "RootView", ->
editor = null
waitsForPromise ->
rootView.open('b').then (o) -> editor = o
atom.rootView.open('b').then (o) -> editor = o
runs ->
expect(activePane.activeItem).toBe editor
@@ -463,9 +463,9 @@ describe "RootView", ->
describe "window:toggle-invisibles event", ->
it "shows/hides invisibles in all open and future editors", ->
rootView.height(200)
rootView.attachToDom()
rightEditor = rootView.getActiveView()
atom.rootView.height(200)
atom.rootView.attachToDom()
rightEditor = atom.rootView.getActiveView()
rightEditor.setText(" \t ")
leftEditor = rightEditor.splitLeft()
expect(rightEditor.find(".line:first").text()).toBe " "
@@ -473,14 +473,14 @@ describe "RootView", ->
withInvisiblesShowing = "#{rightEditor.invisibles.space}#{rightEditor.invisibles.tab} #{rightEditor.invisibles.space}#{rightEditor.invisibles.eol}"
rootView.trigger "window:toggle-invisibles"
atom.rootView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe withInvisiblesShowing
expect(leftEditor.find(".line:first").text()).toBe withInvisiblesShowing
lowerLeftEditor = leftEditor.splitDown()
expect(lowerLeftEditor.find(".line:first").text()).toBe withInvisiblesShowing
rootView.trigger "window:toggle-invisibles"
atom.rootView.trigger "window:toggle-invisibles"
expect(rightEditor.find(".line:first").text()).toBe " "
expect(leftEditor.find(".line:first").text()).toBe " "
@@ -489,7 +489,7 @@ describe "RootView", ->
describe ".eachEditor(callback)", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
it "invokes the callback for existing editor", ->
count = 0
@@ -497,9 +497,9 @@ describe "RootView", ->
callback = (editor) ->
callbackEditor = editor
count++
rootView.eachEditor(callback)
atom.rootView.eachEditor(callback)
expect(count).toBe 1
expect(callbackEditor).toBe rootView.getActiveView()
expect(callbackEditor).toBe atom.rootView.getActiveView()
it "invokes the callback for new editor", ->
count = 0
@@ -508,28 +508,28 @@ describe "RootView", ->
callbackEditor = editor
count++
rootView.eachEditor(callback)
atom.rootView.eachEditor(callback)
count = 0
callbackEditor = null
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 1
expect(callbackEditor).toBe rootView.getActiveView()
expect(callbackEditor).toBe atom.rootView.getActiveView()
it "returns a subscription that can be disabled", ->
count = 0
callback = (editor) -> count++
subscription = rootView.eachEditor(callback)
subscription = atom.rootView.eachEditor(callback)
expect(count).toBe 1
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 2
subscription.off()
rootView.getActiveView().splitRight()
atom.rootView.getActiveView().splitRight()
expect(count).toBe 2
describe ".eachBuffer(callback)", ->
beforeEach ->
rootView.attachToDom()
atom.rootView.attachToDom()
it "invokes the callback for existing buffer", ->
count = 0
@@ -538,9 +538,9 @@ describe "RootView", ->
callback = (buffer) ->
callbackBuffer = buffer
count++
rootView.eachBuffer(callback)
atom.rootView.eachBuffer(callback)
expect(count).toBe 1
expect(callbackBuffer).toBe rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()
it "invokes the callback for new buffer", ->
count = 0
@@ -549,9 +549,9 @@ describe "RootView", ->
callbackBuffer = buffer
count++
rootView.eachBuffer(callback)
atom.rootView.eachBuffer(callback)
count = 0
callbackBuffer = null
rootView.openSync(require.resolve('./fixtures/sample.txt'))
atom.rootView.openSync(require.resolve('./fixtures/sample.txt'))
expect(count).toBe 1
expect(callbackBuffer).toBe rootView.getActiveView().getBuffer()
expect(callbackBuffer).toBe atom.rootView.getActiveView().getBuffer()

View File

@@ -4,7 +4,7 @@ describe "Selection", ->
[buffer, editor, selection] = []
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
editor = new Editor(buffer: buffer, tabLength: 2)
selection = editor.getSelection()

View File

@@ -49,7 +49,6 @@ beforeEach ->
$.fx.off = true
projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures')
atom.project = atom.getWindowState().set('project', new Project(path: projectPath))
window.project = atom.project
atom.keymap.keyBindings = _.clone(keyBindingsToRestore)
window.resetTimeouts()
@@ -105,14 +104,10 @@ afterEach ->
atom.packages.deactivatePackages()
atom.menu.template = []
window.rootView?.remove?()
atom.rootView?.remove?() if atom.rootView isnt window.rootView
window.rootView = null
atom.rootView?.remove?()
atom.rootView = null
window.project?.destroy?()
atom.project?.destroy?() if atom.project isnt window.project
window.project = null
atom.project?.destroy?()
atom.project = null
$('#jasmine-content').empty() unless window.debugContent

View File

@@ -10,7 +10,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = require.resolve('./fixtures/sample.js')
fileContents = fs.readFileSync(filePath, 'utf8')
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
afterEach ->
buffer?.destroy()
@@ -24,12 +24,12 @@ describe 'TextBuffer', ->
describe "when a file exists for the path", ->
it "loads the contents of that file", ->
filePath = require.resolve './fixtures/sample.txt'
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
expect(buffer.getText()).toBe fs.readFileSync(filePath, 'utf8')
it "does not allow the initial state of the buffer to be undone", ->
filePath = require.resolve './fixtures/sample.txt'
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
buffer.undo()
expect(buffer.getText()).toBe fs.readFileSync(filePath, 'utf8')
@@ -37,13 +37,13 @@ describe 'TextBuffer', ->
it "is modified and is initially empty", ->
filePath = "does-not-exist.txt"
expect(fs.existsSync(filePath)).toBeFalsy()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
expect(buffer.isModified()).toBeTruthy()
expect(buffer.getText()).toBe ''
describe "when no path is given", ->
it "creates an empty buffer", ->
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
expect(buffer .getText()).toBe ""
describe "path-changed event", ->
@@ -53,7 +53,7 @@ describe 'TextBuffer', ->
filePath = path.join(__dirname, "fixtures", "atom-manipulate-me")
newPath = "#{filePath}-i-moved"
fs.writeFileSync(filePath, "")
bufferToChange = project.bufferForPathSync(filePath)
bufferToChange = atom.project.bufferForPathSync(filePath)
eventHandler = jasmine.createSpy('eventHandler')
bufferToChange.on 'path-changed', eventHandler
@@ -85,7 +85,7 @@ describe 'TextBuffer', ->
buffer.release()
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "first")
buffer = project.bufferForPathSync(filePath).retain()
buffer = atom.project.bufferForPathSync(filePath).retain()
afterEach ->
buffer.release()
@@ -156,7 +156,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = path.join(temp.dir, 'atom-file-to-delete.txt')
fs.writeFileSync(filePath, 'delete me')
bufferToDelete = project.bufferForPathSync(filePath)
bufferToDelete = atom.project.bufferForPathSync(filePath)
filePath = bufferToDelete.getPath() # symlinks may have been converted
expect(bufferToDelete.getPath()).toBe filePath
@@ -214,7 +214,7 @@ describe 'TextBuffer', ->
buffer.release()
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, 'delete me')
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@@ -227,7 +227,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, '')
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@@ -251,7 +251,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'atom-tmp-file')
fs.writeFileSync(filePath, '')
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@@ -275,7 +275,7 @@ describe 'TextBuffer', ->
fs.removeSync(filePath) if fs.existsSync(filePath)
expect(fs.existsSync(filePath)).toBeFalsy()
buffer.release()
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
modifiedHandler = jasmine.createSpy("modifiedHandler")
buffer.on 'modified-status-changed', modifiedHandler
@@ -298,12 +298,12 @@ describe 'TextBuffer', ->
it "returns false for an empty buffer with no path", ->
buffer.release()
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
expect(buffer.isModified()).toBeFalsy()
it "returns true for a non-empty buffer with no path", ->
buffer.release()
buffer = project.bufferForPathSync(null)
buffer = atom.project.bufferForPathSync(null)
buffer.setText('a')
expect(buffer.isModified()).toBeTruthy()
buffer.setText('\n')
@@ -312,7 +312,7 @@ describe 'TextBuffer', ->
it "returns false until the buffer is fully loaded", ->
buffer.release()
buffer = new TextBuffer({filePath: temp.openSync('atom').path})
project.addBuffer(buffer)
atom.project.addBuffer(buffer)
expect(buffer.isModified()).toBeFalsy()
@@ -466,7 +466,7 @@ describe 'TextBuffer', ->
beforeEach ->
filePath = path.join(temp.dir, 'temp.txt')
fs.writeFileSync(filePath, "")
saveBuffer = project.bufferForPathSync(filePath)
saveBuffer = atom.project.bufferForPathSync(filePath)
saveBuffer.setText("blah")
it "saves the contents of the buffer to the path", ->
@@ -500,7 +500,7 @@ describe 'TextBuffer', ->
describe "when the buffer has no path", ->
it "throws an exception", ->
saveBuffer = project.bufferForPathSync(null)
saveBuffer = atom.project.bufferForPathSync(null)
saveBuffer.setText "hi"
expect(-> saveBuffer.save()).toThrow()
@@ -524,7 +524,7 @@ describe 'TextBuffer', ->
filePath = path.join(temp.dir, 'temp.txt')
fs.removeSync filePath if fs.existsSync(filePath)
saveAsBuffer = project.bufferForPathSync(null).retain()
saveAsBuffer = atom.project.bufferForPathSync(null).retain()
eventHandler = jasmine.createSpy('eventHandler')
saveAsBuffer.on 'path-changed', eventHandler
@@ -539,7 +539,7 @@ describe 'TextBuffer', ->
newPath = path.join(temp.dir, 'new.txt')
fs.writeFileSync(originalPath, "")
saveAsBuffer = project.bufferForPathSync(originalPath).retain()
saveAsBuffer = atom.project.bufferForPathSync(originalPath).retain()
changeHandler = jasmine.createSpy('changeHandler')
saveAsBuffer.on 'changed', changeHandler
saveAsBuffer.saveAs(newPath)
@@ -904,7 +904,7 @@ describe 'TextBuffer', ->
filePath = temp.openSync('atom').path
fs.writeFileSync(filePath, "words")
buffer = project.bufferForPathSync(filePath)
buffer = atom.project.bufferForPathSync(filePath)
afterEach ->
buffer2?.release()
@@ -966,13 +966,13 @@ describe 'TextBuffer', ->
it "restores the previous unsaved state of the buffer", ->
buffer.release()
buffer = project.bufferForPathSync()
buffer = atom.project.bufferForPathSync()
buffer.setText("abc")
state = buffer.getState().clone()
expect(state.get('path')).toBeUndefined()
expect(state.getObject('text')).toBe 'abc'
buffer2 = project.addBuffer(new TextBuffer(state))
buffer2 = atom.project.addBuffer(new TextBuffer(state))
expect(buffer2.getPath()).toBeUndefined()
expect(buffer2.getText()).toBe("abc")

View File

@@ -447,7 +447,7 @@ describe "TextMateGrammar", ->
describe "when the grammar is added", ->
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.setText("// http://github.com")
{tokens} = editor.lineForScreenRow(0)
@@ -462,7 +462,7 @@ describe "TextMateGrammar", ->
describe "when the grammar is updated", ->
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
editor = project.openSync('sample.js')
editor = atom.project.openSync('sample.js')
editor.setText("// SELECT * FROM OCTOCATS")
{tokens} = editor.lineForScreenRow(0)

View File

@@ -80,7 +80,7 @@ describe "ThemeManager", ->
describe "requireStylesheet(path)", ->
it "synchronously loads css at the given path and installs a style tag for it in the head", ->
cssPath = project.resolve('css.css')
cssPath = atom.project.resolve('css.css')
lengthBefore = $('head style').length
themeManager.requireStylesheet(cssPath)
@@ -97,7 +97,7 @@ describe "ThemeManager", ->
$('head style[id*="css.css"]').remove()
it "synchronously loads and parses less files at the given path and installs a style tag for it in the head", ->
lessPath = project.resolve('sample.less')
lessPath = atom.project.resolve('sample.less')
lengthBefore = $('head style').length
themeManager.requireStylesheet(lessPath)
expect($('head style').length).toBe lengthBefore + 1
@@ -121,9 +121,9 @@ describe "ThemeManager", ->
it "supports requiring css and less stylesheets without an explicit extension", ->
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'css')
expect($('head style[id*="css.css"]').attr('id')).toBe themeManager.stringToId(project.resolve('css.css'))
expect($('head style[id*="css.css"]').attr('id')).toBe themeManager.stringToId(atom.project.resolve('css.css'))
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'sample')
expect($('head style[id*="sample.less"]').attr('id')).toBe themeManager.stringToId(project.resolve('sample.less'))
expect($('head style[id*="sample.less"]').attr('id')).toBe themeManager.stringToId(atom.project.resolve('sample.less'))
$('head style[id*="css.css"]').remove()
$('head style[id*="sample.less"]').remove()
@@ -140,16 +140,16 @@ describe "ThemeManager", ->
describe "base stylesheet loading", ->
beforeEach ->
window.rootView = new RootView
rootView.append $$ -> @div class: 'editor'
rootView.attachToDom()
atom.rootView = new RootView
atom.rootView.append $$ -> @div class: 'editor'
atom.rootView.attachToDom()
themeManager.activateThemes()
it "loads the correct values from the theme's ui-variables file", ->
atom.config.set('core.themes', ['theme-with-ui-variables'])
# an override loaded in the base css
expect(rootView.css("background-color")).toBe "rgb(0, 0, 255)"
expect(atom.rootView.css("background-color")).toBe "rgb(0, 0, 255)"
# from within the theme itself
expect($(".editor").css("padding-top")).toBe "150px"

View File

@@ -20,7 +20,7 @@ describe "TokenizedBuffer", ->
describe "@deserialize(state)", ->
it "constructs a tokenized buffer with the same buffer and tabLength setting", ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer1 = new TokenizedBuffer(buffer: buffer, tabLength: 4)
tokenizedBuffer2 = atom.deserializers.deserialize(tokenizedBuffer1.serialize())
expect(tokenizedBuffer2.buffer).toBe tokenizedBuffer1.buffer
@@ -28,7 +28,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer is destroyed", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
@@ -40,7 +40,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains soft-tabs", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
tokenizedBuffer.on "changed", changeHandler = jasmine.createSpy('changeHandler')
@@ -320,7 +320,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains hard-tabs", ->
beforeEach ->
atom.packages.activatePackage('language-coffee-script', sync: true)
buffer = project.bufferForPathSync('sample-with-tabs.coffee')
buffer = atom.project.bufferForPathSync('sample-with-tabs.coffee')
tokenizedBuffer = new TokenizedBuffer({buffer})
startTokenizing(tokenizedBuffer)
@@ -350,7 +350,7 @@ describe "TokenizedBuffer", ->
describe "when the buffer contains surrogate pairs", ->
beforeEach ->
atom.packages.activatePackage('language-javascript', sync: true)
buffer = project.bufferForPathSync 'sample-with-pairs.js'
buffer = atom.project.bufferForPathSync 'sample-with-pairs.js'
buffer.setText """
'abc\uD835\uDF97def'
//\uD835\uDF97xyz
@@ -390,7 +390,7 @@ describe "TokenizedBuffer", ->
atom.packages.activatePackage('language-ruby-on-rails', sync: true)
atom.packages.activatePackage('language-ruby', sync: true)
buffer = project.bufferForPathSync()
buffer = atom.project.bufferForPathSync()
buffer.setText "<div class='name'><%= User.find(2).full_name %></div>"
tokenizedBuffer = new TokenizedBuffer({buffer})
tokenizedBuffer.setGrammar(atom.syntax.selectGrammar('test.erb'))
@@ -410,7 +410,7 @@ describe "TokenizedBuffer", ->
buffer.release()
it "returns the correct token (regression)", ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)
expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"]
@@ -419,7 +419,7 @@ describe "TokenizedBuffer", ->
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
beforeEach ->
buffer = project.bufferForPathSync('sample.js')
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)

View File

@@ -8,11 +8,11 @@ describe "Window", ->
beforeEach ->
spyOn(atom, 'hide')
atom.getLoadSettings() # Causes atom.loadSettings to be initialized
atom.loadSettings.initialPath = project.getPath()
project.destroy()
atom.loadSettings.initialPath = atom.project.getPath()
atom.project.destroy()
windowEventHandler = new WindowEventHandler()
window.deserializeEditorWindow()
projectPath = project.getPath()
projectPath = atom.project.getPath()
afterEach ->
windowEventHandler.unsubscribe()
@@ -59,31 +59,31 @@ describe "Window", ->
describe "when pane items are are modified", ->
it "prompts user to save and and calls rootView.confirmClose", ->
spyOn(rootView, 'confirmClose').andCallThrough()
spyOn(atom.rootView, 'confirmClose').andCallThrough()
spyOn(atom, "confirmSync").andReturn(2)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(rootView.confirmClose).toHaveBeenCalled()
expect(atom.rootView.confirmClose).toHaveBeenCalled()
expect(atom.confirmSync).toHaveBeenCalled()
it "prompts user to save and handler returns true if don't save", ->
spyOn(atom, "confirmSync").andReturn(2)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirmSync).toHaveBeenCalled()
it "prompts user to save and handler returns false if dialog is canceled", ->
spyOn(atom, "confirmSync").andReturn(1)
editor = rootView.openSync("sample.js")
editor = atom.rootView.openSync("sample.js")
editor.insertText("I look different, I feel different.")
$(window).trigger(beforeUnloadEvent)
expect(atom.confirmSync).toHaveBeenCalled()
describe ".unloadEditorWindow()", ->
it "saves the serialized state of the window so it can be deserialized after reload", ->
rootViewState = rootView.serialize()
rootViewState = atom.rootView.serialize()
syntaxState = atom.syntax.serialize()
window.unloadEditorWindow()
@@ -93,11 +93,11 @@ describe "Window", ->
expect(atom.saveWindowState).toHaveBeenCalled()
it "unsubscribes from all buffers", ->
rootView.openSync('sample.js')
buffer = rootView.getActivePaneItem().buffer
pane = rootView.getActivePane()
atom.rootView.openSync('sample.js')
buffer = atom.rootView.getActivePaneItem().buffer
pane = atom.rootView.getActivePane()
pane.splitRight(pane.copyActiveItem())
expect(window.rootView.find('.editor').length).toBe 2
expect(atom.rootView.find('.editor').length).toBe 2
window.unloadEditorWindow()

View File

@@ -216,18 +216,14 @@ class AtomPackage extends Package
@activateStylesheets()
@requireMainModule()
# Private: TODO remove once packages have been updated
getRootView: ->
atom?.rootView ? window.rootView
subscribeToActivationEvents: ->
return unless @metadata.activationEvents?
if _.isArray(@metadata.activationEvents)
@getRootView().command(event, @handleActivationEvent) for event in @metadata.activationEvents
atom.rootView.command(event, @handleActivationEvent) for event in @metadata.activationEvents
else if _.isString(@metadata.activationEvents)
@getRootView().command(@metadata.activationEvents, @handleActivationEvent)
atom.rootView.command(@metadata.activationEvents, @handleActivationEvent)
else
@getRootView().command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
atom.rootView.command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
handleActivationEvent: (event) =>
bubblePathEventHandlers = @disableEventHandlersOnBubblePath(event)
@@ -238,11 +234,11 @@ class AtomPackage extends Package
unsubscribeFromActivationEvents: ->
if _.isArray(@metadata.activationEvents)
@getRootView().off(event, @handleActivationEvent) for event in @metadata.activationEvents
atom.rootView.off(event, @handleActivationEvent) for event in @metadata.activationEvents
else if _.isString(@metadata.activationEvents)
@getRootView().off(@metadata.activationEvents, @handleActivationEvent)
atom.rootView.off(@metadata.activationEvents, @handleActivationEvent)
else
@getRootView().off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
atom.rootView.off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents
disableEventHandlersOnBubblePath: (event) ->
bubblePathEventHandlers = []

View File

@@ -173,7 +173,7 @@ class Atom
callback(showSaveDialogSync())
showSaveDialogSync: (defaultPath) ->
defaultPath ?= project?.getPath()
defaultPath ?= @project?.getPath()
currentWindow = @getCurrentWindow()
dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath}

View File

@@ -1048,7 +1048,7 @@ class EditorView extends View
remove: (selector, keepData) ->
return super if keepData or @removed
super
rootView?.focus()
atom.rootView?.focus()
beforeRemove: ->
@trigger 'editor:will-be-removed'

View File

@@ -107,13 +107,14 @@ class Editor
when 'scrollLeft'
@emit 'scroll-left-changed', newValue
project.addEditSession(this) if registerEditSession
atom.project.addEditSession(this) if registerEditSession
# Private:
setBuffer: (@buffer) ->
@buffer.retain()
@subscribe @buffer, "path-changed", =>
project.setPath(path.dirname(@getPath())) unless project.getPath()?
unless atom.project.getPath()?
atom.project.setPath(path.dirname(@getPath()))
@emit "title-changed"
@emit "path-changed"
@subscribe @buffer, "contents-modified", => @emit "contents-modified"
@@ -142,7 +143,7 @@ class Editor
@buffer.release()
@displayBuffer.destroy()
@languageMode.destroy()
project?.removeEditSession(this)
atom.project?.removeEditSession(this)
@emit 'destroyed'
@off()
@@ -162,7 +163,7 @@ class Editor
newEditSession.setScrollLeft(@getScrollLeft())
for marker in @findMarkers(editorId: @id)
marker.copy(editorId: newEditSession.id, preserveFolds: true)
project.addEditSession(newEditSession)
atom.project.addEditSession(newEditSession)
newEditSession
# Public: Retrieves the filename of the open file.

View File

@@ -61,7 +61,7 @@ class Git
@statuses = {}
@upstream = {ahead: 0, behind: 0}
{project, refreshOnWindowFocus} = options
{@project, refreshOnWindowFocus} = options
refreshOnWindowFocus ?= true
if refreshOnWindowFocus
@@ -70,8 +70,8 @@ class Git
@refreshIndex()
@refreshStatus()
if project?
@subscribe project.buffers.onEach (buffer) => @subscribeToBuffer(buffer)
if @project?
@subscribe @project.buffers.onEach (buffer) => @subscribeToBuffer(buffer)
# Private: Subscribes to buffer events.
subscribeToBuffer: (buffer) ->
@@ -145,7 +145,7 @@ class Git
# Public: Returns true if at the root, false if in a subfolder of the
# repository.
isProjectAtRoot: ->
@projectAtRoot ?= project.relativize(@getWorkingDirectory()) is ''
@projectAtRoot ?= @project?.relativize(@getWorkingDirectory()) is ''
# Public: Makes a path relative to the repository's working directory.
relativize: (path) -> @getRepo().relativize(path)

View File

@@ -141,7 +141,7 @@ class Keymap
handleKeyEvent: (event) ->
element = event.target
element = rootView if element == document.body
element = atom.rootView if element == document.body
keystroke = @keystrokeStringForEvent(event, @queuedKeystroke)
keyBindings = @keyBindingsForKeystrokeMatchingElement(keystroke, element)

View File

@@ -427,7 +427,7 @@ class Pane extends View
# Private:
beforeRemove: ->
if @is(':has(:focus)')
@getContainer().focusNextPane() or rootView?.focus()
@getContainer().focusNextPane() or atom.rootView?.focus()
else if @isActive()
@getContainer().makeNextPaneActive()

View File

@@ -85,7 +85,7 @@ class RootView extends View
@subscribe $(window), 'focus', (e) =>
@handleFocus(e) if document.activeElement is document.body
project.on 'path-changed', => @updateTitle()
atom.project.on 'path-changed', => @updateTitle()
@on 'pane-container:active-pane-item-changed', => @updateTitle()
@on 'pane:active-item-title-changed', '.active.pane', => @updateTitle()
@@ -105,7 +105,7 @@ class RootView extends View
@command 'application:zoom', -> ipc.sendChannel('command', 'application:zoom')
@command 'application:bring-all-windows-to-front', -> ipc.sendChannel('command', 'application:bring-all-windows-to-front')
@command 'window:run-package-specs', => ipc.sendChannel('run-package-specs', path.join(project.getPath(), 'spec'))
@command 'window:run-package-specs', => ipc.sendChannel('run-package-specs', path.join(atom.project.getPath(), 'spec'))
@command 'window:increase-font-size', =>
atom.config.set("editor.fontSize", atom.config.get("editor.fontSize") + 1)
@@ -172,12 +172,12 @@ class RootView extends View
# Returns a promise that resolves to the {Editor} for the file URI.
open: (filePath, options={}) ->
changeFocus = options.changeFocus ? true
filePath = project.resolve(filePath)
filePath = atom.project.resolve(filePath)
initialLine = options.initialLine
activePane = @getActivePane()
editor = activePane.itemForUri(project.relativize(filePath)) if activePane and filePath
promise = project.open(filePath, {initialLine}) if not editor
editor = activePane.itemForUri(atom.project.relativize(filePath)) if activePane and filePath
promise = atom.project.open(filePath, {initialLine}) if not editor
Q(editor ? promise)
.then (editor) =>
@@ -196,13 +196,13 @@ class RootView extends View
openSync: (uri, {changeFocus, initialLine, pane, split}={}) ->
changeFocus ?= true
pane ?= @getActivePane()
uri = project.relativize(uri)
uri = atom.project.relativize(uri)
if pane
if uri
paneItem = pane.itemForUri(uri) ? project.openSync(uri, {initialLine})
paneItem = pane.itemForUri(uri) ? atom.project.openSync(uri, {initialLine})
else
paneItem = project.openSync()
paneItem = atom.project.openSync()
if split == 'right'
panes = @getPanes()
@@ -215,7 +215,7 @@ class RootView extends View
pane.showItem(paneItem)
else
paneItem = project.openSync(uri, {initialLine})
paneItem = atom.project.openSync(uri, {initialLine})
pane = new Pane(paneItem)
@panes.setRoot(pane)
@@ -224,7 +224,7 @@ class RootView extends View
openSingletonSync: (uri, {changeFocus, initialLine, split}={}) ->
changeFocus ?= true
uri = project.relativize(uri)
uri = atom.project.relativize(uri)
pane = @panes.paneForUri(uri)
if pane
@@ -237,7 +237,7 @@ class RootView extends View
# Public: Updates the application's title, based on whichever file is open.
updateTitle: ->
if projectPath = project.getPath()
if projectPath = atom.project.getPath()
if item = @getActivePaneItem()
@setTitle("#{item.getTitle?() ? 'untitled'} - #{projectPath}")
else
@@ -317,14 +317,14 @@ class RootView extends View
# Public: Fires a callback on each open {Editor}.
eachEditSession: (callback) ->
project.eachEditSession(callback)
atom.project.eachEditSession(callback)
# Private: Fires a callback on each open {TextBuffer}.
eachBuffer: (callback) ->
project.eachBuffer(callback)
atom.project.eachBuffer(callback)
# Private: Destroys everything.
remove: ->
editorView.remove() for editorView in @getEditors()
project?.destroy()
atom.project?.destroy()
super

View File

@@ -171,9 +171,7 @@ class SelectList extends View
if @previouslyFocusedElement?.isOnDom()
@previouslyFocusedElement.focus()
else
# TODO Remove once all packages have been updated
rootView = atom?.rootView ? window.rootView
rootView.focus()
atom.rootView.focus()
# Public:
cancelled: ->

View File

@@ -31,7 +31,7 @@ class TokenizedBuffer
@state = optionsOrState
# TODO: This needs to be made async, but should wait until the new Telepath changes land
@buffer = project.bufferForPathSync(optionsOrState.get('bufferPath'))
@buffer = atom.project.bufferForPathSync(optionsOrState.get('bufferPath'))
else
{ @buffer, tabLength } = optionsOrState
@state = atom.site.createDocument

View File

@@ -72,8 +72,6 @@ window.unloadEditorWindow = ->
atom.rootView.remove()
atom.project.destroy()
windowEventHandler?.unsubscribe()
window.rootView = null
window.project = null
installAtomCommand = (callback) ->
commandPath = path.join(window.resourcePath, 'atom.sh')
@@ -86,9 +84,7 @@ installApmCommand = (callback) ->
window.deserializeEditorWindow = ->
atom.deserializePackageStates()
atom.deserializeProject()
window.project = atom.project
atom.deserializeRootView()
window.rootView = atom.rootView
window.onerror = ->
atom.openDevTools()

2
vendor/apm vendored

Submodule vendor/apm updated: 687d81f5a1...5b499398ae