mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Rename RootView.activeEditor -> getActiveEditor
This commit is contained in:
@@ -10,7 +10,7 @@ describe "editor.", ->
|
||||
window.rootViewParentSelector = '#jasmine-content'
|
||||
window.startup()
|
||||
rootView.project.setPath(require.resolve('benchmark/fixtures'))
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
|
||||
afterEach ->
|
||||
$(window).off 'beforeunload'
|
||||
|
||||
@@ -27,8 +27,8 @@ describe "Atom", ->
|
||||
runs ->
|
||||
expect(atom.windows.length).toBe previousWindowCount + 1
|
||||
newWindow = _.last(atom.windows)
|
||||
expect(newWindow.rootView.activeEditor().buffer.getPath()).toEqual filePath
|
||||
expect(newWindow.rootView.activeEditor().buffer.getText()).toEqual fs.read(filePath)
|
||||
expect(newWindow.rootView.getActiveEditor().buffer.getPath()).toEqual filePath
|
||||
expect(newWindow.rootView.getActiveEditor().buffer.getText()).toEqual fs.read(filePath)
|
||||
|
||||
describe ".windowOpened(window)", ->
|
||||
atom = null
|
||||
|
||||
@@ -23,7 +23,7 @@ describe "Editor", ->
|
||||
beforeEach ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
project = rootView.project
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
buffer = editor.buffer
|
||||
|
||||
editor.attachToDom = ({ heightInLines } = {}) ->
|
||||
@@ -281,7 +281,7 @@ describe "Editor", ->
|
||||
tempFilePath = '/tmp/atom-temp.txt'
|
||||
fs.write(tempFilePath, "")
|
||||
rootView = new RootView(tempFilePath)
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
project = rootView.project
|
||||
|
||||
expect(editor.buffer.getPath()).toBe tempFilePath
|
||||
|
||||
@@ -25,8 +25,8 @@ describe "RootView", ->
|
||||
expect(rootView.project.getPath()).toBe fs.directory(path)
|
||||
expect(rootView.editors().length).toBe 1
|
||||
expect(rootView.editors()[0]).toHaveClass 'active'
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe path
|
||||
expect(rootView.activeEditor().editSessions.length).toBe 1
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe path
|
||||
expect(rootView.getActiveEditor().editSessions.length).toBe 1
|
||||
expect(document.title).toBe path
|
||||
|
||||
describe "when pathToOpen references a directory", ->
|
||||
@@ -52,7 +52,7 @@ describe "RootView", ->
|
||||
rootView.remove()
|
||||
rootView = new RootView
|
||||
rootView.open()
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
buffer = editor1.buffer
|
||||
editor1.splitRight()
|
||||
viewState = rootView.serialize()
|
||||
@@ -61,7 +61,7 @@ describe "RootView", ->
|
||||
rootView = RootView.deserialize(viewState)
|
||||
expect(rootView.project.getPath()?).toBeFalsy()
|
||||
expect(rootView.editors().length).toBe 2
|
||||
expect(rootView.activeEditor().buffer.getText()).toBe buffer.getText()
|
||||
expect(rootView.getActiveEditor().buffer.getText()).toBe buffer.getText()
|
||||
expect(document.title).toBe 'untitled'
|
||||
|
||||
describe "when the serialized RootView has a project", ->
|
||||
@@ -71,7 +71,7 @@ describe "RootView", ->
|
||||
rootView = new RootView(path)
|
||||
rootView.open('dir/a')
|
||||
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = editor1.splitRight()
|
||||
editor3 = editor2.splitRight()
|
||||
editor4 = editor2.splitDown()
|
||||
@@ -153,11 +153,11 @@ describe "RootView", ->
|
||||
|
||||
rootView.open() # create an editor
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
rootView.focus()
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "panes", ->
|
||||
[pane1, newPaneContent] = []
|
||||
@@ -425,7 +425,7 @@ describe "RootView", ->
|
||||
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
keymap = new (require 'keymap')
|
||||
originalKeymap = window.keymap
|
||||
window.keymap = keymap
|
||||
@@ -449,10 +449,10 @@ describe "RootView", ->
|
||||
pathChangeHandler = jasmine.createSpy 'pathChangeHandler'
|
||||
rootView.on 'active-editor-path-change', pathChangeHandler
|
||||
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
expect(document.title).toBe path
|
||||
|
||||
editor2 = rootView.activeEditor().splitLeft()
|
||||
editor2 = rootView.getActiveEditor().splitLeft()
|
||||
|
||||
path = rootView.project.resolve('b')
|
||||
editor2.edit(rootView.project.open(path))
|
||||
@@ -469,7 +469,7 @@ describe "RootView", ->
|
||||
rootView = new RootView
|
||||
rootView.open()
|
||||
expect(rootView.project.getPath()?).toBeFalsy()
|
||||
rootView.activeEditor().buffer.saveAs('/tmp/ignore-me')
|
||||
rootView.getActiveEditor().buffer.saveAs('/tmp/ignore-me')
|
||||
expect(rootView.project.getPath()).toBe '/tmp'
|
||||
|
||||
describe "when editors are focused", ->
|
||||
@@ -477,8 +477,8 @@ describe "RootView", ->
|
||||
pathChangeHandler = jasmine.createSpy 'pathChangeHandler'
|
||||
rootView.on 'active-editor-path-change', pathChangeHandler
|
||||
|
||||
editor1 = rootView.activeEditor()
|
||||
editor2 = rootView.activeEditor().splitLeft()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = rootView.getActiveEditor().splitLeft()
|
||||
|
||||
rootView.open(require.resolve('fixtures/sample.txt'))
|
||||
expect(pathChangeHandler).toHaveBeenCalled()
|
||||
@@ -522,35 +522,35 @@ describe "RootView", ->
|
||||
describe ".open(path, options)", ->
|
||||
describe "when there is no active editor", ->
|
||||
beforeEach ->
|
||||
rootView.activeEditor().destroyActiveEditSession()
|
||||
expect(rootView.activeEditor()).toBeUndefined()
|
||||
rootView.getActiveEditor().destroyActiveEditSession()
|
||||
expect(rootView.getActiveEditor()).toBeUndefined()
|
||||
|
||||
describe "when called with no path", ->
|
||||
it "opens an empty buffer in a new editor", ->
|
||||
rootView.open()
|
||||
expect(rootView.activeEditor()).toBeDefined()
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBeUndefined()
|
||||
expect(rootView.getActiveEditor()).toBeDefined()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBeUndefined()
|
||||
|
||||
describe "when called with a path", ->
|
||||
it "opens a buffer with the given path in a new editor", ->
|
||||
rootView.open('b')
|
||||
expect(rootView.activeEditor()).toBeDefined()
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe require.resolve('fixtures/dir/b')
|
||||
expect(rootView.getActiveEditor()).toBeDefined()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/dir/b')
|
||||
|
||||
describe "when there is an active editor", ->
|
||||
beforeEach ->
|
||||
expect(rootView.activeEditor()).toBeDefined()
|
||||
expect(rootView.getActiveEditor()).toBeDefined()
|
||||
|
||||
describe "when called with no path", ->
|
||||
it "opens an empty buffer in the active editor", ->
|
||||
rootView.open()
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBeUndefined()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBeUndefined()
|
||||
|
||||
describe "when called with a path", ->
|
||||
[editor1, editor2] = []
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = editor1.splitRight()
|
||||
rootView.open('b')
|
||||
editor2.loadPreviousEditSession()
|
||||
@@ -559,7 +559,7 @@ describe "RootView", ->
|
||||
describe "when allowActiveEditorChange is false (the default)", ->
|
||||
activeEditor = null
|
||||
beforeEach ->
|
||||
activeEditor = rootView.activeEditor()
|
||||
activeEditor = rootView.getActiveEditor()
|
||||
|
||||
describe "when the active editor has an edit session for the given path", ->
|
||||
it "re-activates the existing edit session", ->
|
||||
@@ -580,7 +580,7 @@ describe "RootView", ->
|
||||
describe "when the 'allowActiveEditorChange' option is true", ->
|
||||
describe "when the active editor has an edit session for the given path", ->
|
||||
it "re-activates the existing edit session regardless of whether any other editor also has an edit session for the path", ->
|
||||
activeEditor = rootView.activeEditor()
|
||||
activeEditor = rootView.getActiveEditor()
|
||||
expect(activeEditor.buffer.getPath()).toBe require.resolve('fixtures/dir/a')
|
||||
previousEditSession = activeEditor.activeEditSession
|
||||
|
||||
@@ -593,14 +593,14 @@ describe "RootView", ->
|
||||
describe "when the active editor does *not* have an edit session for the given path", ->
|
||||
describe "when another editor has an edit session for the path", ->
|
||||
it "focuses the other editor and activates its edit session for the path", ->
|
||||
expect(rootView.activeEditor()).toBe editor1
|
||||
expect(rootView.getActiveEditor()).toBe editor1
|
||||
rootView.open('b', allowActiveEditorChange: true)
|
||||
expect(rootView.activeEditor()).toBe editor2
|
||||
expect(rootView.getActiveEditor()).toBe editor2
|
||||
expect(editor2.buffer.getPath()).toBe require.resolve('fixtures/dir/b')
|
||||
|
||||
describe "when no other editor has an edit session for the path either", ->
|
||||
it "creates a new edit session for the path on the current active editor", ->
|
||||
path = require.resolve('fixtures/sample.js')
|
||||
rootView.open(path, allowActiveEditorChange: true)
|
||||
expect(rootView.activeEditor()).toBe editor1
|
||||
expect(rootView.getActiveEditor()).toBe editor1
|
||||
expect(editor1.buffer.getPath()).toBe path
|
||||
|
||||
@@ -9,7 +9,7 @@ describe "StatusBar", ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
rootView.simulateDomAttachment()
|
||||
StatusBar.activate(rootView)
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
statusBar = rootView.find('.status-bar').view()
|
||||
|
||||
afterEach ->
|
||||
|
||||
@@ -23,7 +23,7 @@ describe "Window", ->
|
||||
expect($native.reload).toHaveBeenCalled()
|
||||
|
||||
it "shows alert when a modifed buffer exists", ->
|
||||
rootView.activeEditor().insertText("hi")
|
||||
rootView.getActiveEditor().insertText("hi")
|
||||
spyOn($native, "alert")
|
||||
spyOn($native, "reload")
|
||||
window.reload()
|
||||
@@ -55,7 +55,7 @@ describe "Window", ->
|
||||
expect(atom.rootViewStates[$windowNumber]).toEqual JSON.stringify(expectedState)
|
||||
|
||||
it "unsubscribes from all buffers", ->
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = editor1.splitRight()
|
||||
expect(window.rootView.editors().length).toBe 2
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ describe "Autocomplete", ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
rootView.simulateDomAttachment()
|
||||
Autocomplete.activate(rootView)
|
||||
leftEditor = rootView.activeEditor()
|
||||
rightEditor = rootView.activeEditor().splitRight()
|
||||
leftEditor = rootView.getActiveEditor()
|
||||
rightEditor = rootView.getActiveEditor().splitRight()
|
||||
|
||||
spyOn(Autocomplete.prototype, 'initialize')
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ describe "CommandPanel", ->
|
||||
rootView = new RootView
|
||||
rootView.open(require.resolve 'fixtures/sample.js')
|
||||
rootView.enableKeymap()
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
commandPanel = rootView.activateExtension(CommandPanel)
|
||||
|
||||
afterEach ->
|
||||
@@ -30,7 +30,7 @@ describe "CommandPanel", ->
|
||||
it "toggles the command panel", ->
|
||||
rootView.attachToDom()
|
||||
expect(rootView.find('.command-panel')).not.toExist()
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
expect(commandPanel.miniEditor.isFocused).toBeFalsy()
|
||||
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
@@ -43,7 +43,7 @@ describe "CommandPanel", ->
|
||||
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
expect(rootView.find('.command-panel')).not.toExist()
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
expect(commandPanel.miniEditor.isFocused).toBeFalsy()
|
||||
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
@@ -90,7 +90,7 @@ describe "CommandPanel", ->
|
||||
describe "when command-panel:set-selection-as-regex-address is triggered on the root view", ->
|
||||
it "sets the @lastRelativeAddress to a RegexAddress of the current selection", ->
|
||||
rootView.open(require.resolve('fixtures/sample.js'))
|
||||
rootView.activeEditor().setSelectedBufferRange([[1,21],[1,28]])
|
||||
rootView.getActiveEditor().setSelectedBufferRange([[1,21],[1,28]])
|
||||
|
||||
commandInterpreter = commandPanel.commandInterpreter
|
||||
expect(commandInterpreter.lastRelativeAddress).toBeUndefined()
|
||||
@@ -100,7 +100,7 @@ describe "CommandPanel", ->
|
||||
|
||||
describe "when command-panel:find-in-file is triggered on an editor", ->
|
||||
it "pre-populates command panel's editor with /", ->
|
||||
rootView.activeEditor().trigger "command-panel:find-in-file"
|
||||
rootView.getActiveEditor().trigger "command-panel:find-in-file"
|
||||
expect(commandPanel.parent).not.toBeEmpty()
|
||||
expect(commandPanel.miniEditor.getText()).toBe "/"
|
||||
|
||||
@@ -153,10 +153,10 @@ describe "CommandPanel", ->
|
||||
|
||||
describe ".execute()", ->
|
||||
it "executes the command and closes the command panel", ->
|
||||
rootView.activeEditor().setText("i hate love")
|
||||
rootView.activeEditor().getSelection().setBufferRange [[0,0], [0,Infinity]]
|
||||
rootView.getActiveEditor().setText("i hate love")
|
||||
rootView.getActiveEditor().getSelection().setBufferRange [[0,0], [0,Infinity]]
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
commandPanel.miniEditor.insertText 's/hate/love/'
|
||||
commandPanel.execute()
|
||||
expect(rootView.activeEditor().getText()).toBe "i love love"
|
||||
expect(rootView.getActiveEditor().getText()).toBe "i love love"
|
||||
expect(rootView.find('.command-panel')).not.toExist()
|
||||
|
||||
@@ -60,9 +60,9 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = editor1.splitRight()
|
||||
expect(rootView.activeEditor()).toBe editor2
|
||||
expect(rootView.getActiveEditor()).toBe editor2
|
||||
rootView.trigger 'fuzzy-finder:toggle-file-finder'
|
||||
|
||||
describe "when a path is highlighted", ->
|
||||
@@ -121,7 +121,7 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
describe "when the active editor only contains edit sessions for anonymous buffers", ->
|
||||
it "does not open", ->
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
editor.edit(rootView.project.open())
|
||||
editor.loadPreviousEditSession()
|
||||
editor.destroyActiveEditSession()
|
||||
@@ -131,8 +131,8 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
describe "when there is no active editor", ->
|
||||
it "does not open", ->
|
||||
rootView.activeEditor().destroyActiveEditSession()
|
||||
expect(rootView.activeEditor()).toBeUndefined()
|
||||
rootView.getActiveEditor().destroyActiveEditSession()
|
||||
expect(rootView.getActiveEditor()).toBeUndefined()
|
||||
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
|
||||
expect(rootView.find('.fuzzy-finder')).not.toExist()
|
||||
|
||||
@@ -141,9 +141,9 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
editor1 = rootView.activeEditor()
|
||||
editor1 = rootView.getActiveEditor()
|
||||
editor2 = editor1.splitRight()
|
||||
expect(rootView.activeEditor()).toBe editor2
|
||||
expect(rootView.getActiveEditor()).toBe editor2
|
||||
rootView.open('sample.txt')
|
||||
editor2.loadPreviousEditSession()
|
||||
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
|
||||
@@ -169,7 +169,7 @@ describe 'FuzzyFinder', ->
|
||||
editor1.focus()
|
||||
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
|
||||
|
||||
expect(rootView.activeEditor()).toBe editor1
|
||||
expect(rootView.getActiveEditor()).toBe editor1
|
||||
|
||||
finder.moveDown()
|
||||
selectedLi = finder.findSelectedLi()
|
||||
@@ -252,7 +252,7 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
it "focuses previously focused element", ->
|
||||
rootView.attachToDom()
|
||||
activeEditor = rootView.activeEditor()
|
||||
activeEditor = rootView.getActiveEditor()
|
||||
activeEditor.focus()
|
||||
|
||||
rootView.trigger 'fuzzy-finder:toggle-file-finder'
|
||||
@@ -271,13 +271,13 @@ describe 'FuzzyFinder', ->
|
||||
selectedLi = finder.find('li:eq(1)')
|
||||
|
||||
expectedPath = rootView.project.resolve(selectedLi.text())
|
||||
expect(rootView.activeEditor().buffer.getPath()).not.toBe expectedPath
|
||||
expect(rootView.activeEditor().isFocused).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).not.toBe expectedPath
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
selectedLi.mousedown()
|
||||
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe expectedPath
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe expectedPath
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe ".findMatches(queryString)", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -10,7 +10,7 @@ describe "Snippets extension", ->
|
||||
beforeEach ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
rootView.activateExtension(Snippets)
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
buffer = editor.buffer
|
||||
rootView.simulateDomAttachment()
|
||||
rootView.enableKeymap()
|
||||
|
||||
@@ -12,7 +12,7 @@ describe "StripTrailingWhitespace", ->
|
||||
|
||||
StripTrailingWhitespace.activate(rootView)
|
||||
rootView.focus()
|
||||
editor = rootView.activeEditor()
|
||||
editor = rootView.getActiveEditor()
|
||||
|
||||
afterEach ->
|
||||
fs.remove(path) if fs.exists(path)
|
||||
|
||||
@@ -167,28 +167,28 @@ describe "TreeView", ->
|
||||
|
||||
describe "when a file is single-clicked", ->
|
||||
it "selects the files and opens it in the active editor, without changing focus", ->
|
||||
expect(rootView.activeEditor()).toBeUndefined()
|
||||
expect(rootView.getActiveEditor()).toBeUndefined()
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.activeEditor().isFocused).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
sampleTxt.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.txt')
|
||||
expect(rootView.activeEditor().isFocused).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.txt')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
describe "when a file is double-clicked", ->
|
||||
it "selects the file and opens it in the active editor on the first click, then changes focus to the active editor on the second", ->
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.activeEditor().isFocused).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 2 })
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "when a directory is single-clicked", ->
|
||||
it "is selected", ->
|
||||
@@ -204,7 +204,7 @@ describe "TreeView", ->
|
||||
expect(subdir).toHaveClass 'selected'
|
||||
subdir.trigger clickEvent(originalEvent: { detail: 2 })
|
||||
expect(subdir).toHaveClass 'expanded'
|
||||
expect(rootView.activeEditor().isFocused).toBeFalsy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
describe "when a new file is opened in the active editor", ->
|
||||
it "is selected in the tree view if the file's entry visible", ->
|
||||
@@ -228,7 +228,7 @@ describe "TreeView", ->
|
||||
describe "when a different editor becomes active", ->
|
||||
it "selects the file in that is open in that editor", ->
|
||||
sampleJs.click()
|
||||
leftEditor = rootView.activeEditor()
|
||||
leftEditor = rootView.getActiveEditor()
|
||||
rightEditor = leftEditor.splitRight()
|
||||
sampleTxt.click()
|
||||
|
||||
@@ -391,7 +391,7 @@ describe "TreeView", ->
|
||||
it "opens the file in the editor", ->
|
||||
treeView.root.find('.file:contains(sample.js)').click()
|
||||
treeView.root.trigger 'tree-view:open-selected-entry'
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
it "expands or collapses the directory", ->
|
||||
@@ -407,7 +407,7 @@ describe "TreeView", ->
|
||||
describe "when nothing is selected", ->
|
||||
it "does nothing", ->
|
||||
treeView.root.trigger 'tree-view:open-selected-entry'
|
||||
expect(rootView.activeEditor()).toBeUndefined()
|
||||
expect(rootView.getActiveEditor()).toBeUndefined()
|
||||
|
||||
describe "file modification", ->
|
||||
[dirView, fileView, rootDirPath, dirPath, filePath] = []
|
||||
@@ -470,7 +470,7 @@ describe "TreeView", ->
|
||||
expect(fs.exists(newPath)).toBeTruthy()
|
||||
expect(fs.isFile(newPath)).toBeTruthy()
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().buffer.getPath()).toBe newPath
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe newPath
|
||||
|
||||
waitsFor "tree view to be updated", ->
|
||||
dirView.entries.find("> .file").length > 1
|
||||
@@ -499,7 +499,7 @@ describe "TreeView", ->
|
||||
expect(fs.exists(newPath)).toBeTruthy()
|
||||
expect(fs.isDirectory(newPath)).toBeTruthy()
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().buffer.getPath()).not.toBe newPath
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).not.toBe newPath
|
||||
|
||||
describe "when a or directory already exists at the given path", ->
|
||||
it "shows an error message and does not close the dialog", ->
|
||||
@@ -525,7 +525,7 @@ describe "TreeView", ->
|
||||
rootView.attachToDom()
|
||||
rootView.focus()
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
it "opens an add dialog with the directory's path populated", ->
|
||||
@@ -626,7 +626,7 @@ describe "TreeView", ->
|
||||
rootView.attachToDom()
|
||||
rootView.focus()
|
||||
expect(moveDialog.parent()).not.toExist()
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "tree-view:remove", ->
|
||||
it "shows the native alert dialog", ->
|
||||
|
||||
@@ -48,8 +48,8 @@ class RootView extends View
|
||||
handleEvents: ->
|
||||
@on 'toggle-dev-tools', => window.toggleDevTools()
|
||||
@on 'focus', (e) =>
|
||||
if @activeEditor()
|
||||
@activeEditor().focus()
|
||||
if @getActiveEditor()
|
||||
@getActiveEditor().focus()
|
||||
false
|
||||
else
|
||||
@setTitle(@project?.getPath())
|
||||
@@ -105,7 +105,7 @@ class RootView extends View
|
||||
@makeEditorActive(editor)
|
||||
|
||||
openInExistingEditor: (path, allowActiveEditorChange) ->
|
||||
if activeEditor = @activeEditor()
|
||||
if activeEditor = @getActiveEditor()
|
||||
path = @project.resolve(path) if path
|
||||
|
||||
if activeEditor.activateEditSessionForPath(path)
|
||||
@@ -156,7 +156,7 @@ class RootView extends View
|
||||
getOpenBufferPaths: ->
|
||||
_.uniq(_.flatten(@editors().map (editor) -> editor.getOpenBufferPaths()))
|
||||
|
||||
activeEditor: ->
|
||||
getActiveEditor: ->
|
||||
if (editor = @panes.find('.editor.active')).length
|
||||
editor.view()
|
||||
else
|
||||
|
||||
@@ -64,7 +64,7 @@ class CommandPanel extends View
|
||||
|
||||
execute: (command = @miniEditor.getText()) ->
|
||||
try
|
||||
@commandInterpreter.eval(@rootView.activeEditor(), command)
|
||||
@commandInterpreter.eval(@rootView.getActiveEditor(), command)
|
||||
catch error
|
||||
if error instanceof SyntaxError
|
||||
@flashError()
|
||||
@@ -87,12 +87,12 @@ class CommandPanel extends View
|
||||
@miniEditor.setText(@history[@historyIndex] or '')
|
||||
|
||||
repeatRelativeAddress: ->
|
||||
@commandInterpreter.repeatRelativeAddress(@rootView.activeEditor())
|
||||
@commandInterpreter.repeatRelativeAddress(@rootView.getActiveEditor())
|
||||
|
||||
repeatRelativeAddressInReverse: ->
|
||||
@commandInterpreter.repeatRelativeAddressInReverse(@rootView.activeEditor())
|
||||
@commandInterpreter.repeatRelativeAddressInReverse(@rootView.getActiveEditor())
|
||||
|
||||
setSelectionAsLastRelativeAddress: ->
|
||||
selection = @rootView.activeEditor().getSelectedText()
|
||||
selection = @rootView.getActiveEditor().getSelectedText()
|
||||
regex = _.escapeRegExp(selection)
|
||||
@commandInterpreter.lastRelativeAddress = new CompositeCommand([new RegexAddress(regex)])
|
||||
|
||||
@@ -53,7 +53,7 @@ class TreeView extends View
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
@rootView.project.on 'path-change', => @updateRoot()
|
||||
|
||||
@on 'tree-view:unfocus', => @rootView.activeEditor()?.focus()
|
||||
@on 'tree-view:unfocus', => @rootView.getActiveEditor()?.focus()
|
||||
@rootView.on 'tree-view:focus', => this.focus()
|
||||
|
||||
@selectEntry(@root) if @root
|
||||
@@ -89,7 +89,7 @@ class TreeView extends View
|
||||
@openSelectedEntry() if (entry instanceof FileView)
|
||||
when 2
|
||||
if entry.is('.selected.file')
|
||||
@rootView.activeEditor().focus()
|
||||
@rootView.getActiveEditor().focus()
|
||||
else if entry.is('.selected.directory')
|
||||
entry.toggleExpansion()
|
||||
|
||||
@@ -101,7 +101,7 @@ class TreeView extends View
|
||||
@append(@root)
|
||||
|
||||
selectActiveFile: ->
|
||||
activeFilePath = @rootView.activeEditor()?.buffer.getPath()
|
||||
activeFilePath = @rootView.getActiveEditor()?.buffer.getPath()
|
||||
@selectEntryForPath(activeFilePath)
|
||||
|
||||
selectEntryForPath: (path) ->
|
||||
|
||||
Reference in New Issue
Block a user