From 6d7a6f9a9227df47f5bba3be1c6d32cf14c59ff4 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 4 Jul 2012 12:40:17 -0600 Subject: [PATCH] :lipstick: Replace editor.getBuffer().getPath() w/ editor.getPath() --- spec/app/atom-spec.coffee | 2 +- spec/app/editor-spec.coffee | 4 ++-- spec/app/root-view-spec.coffee | 26 +++++++++++------------ spec/extensions/fuzzy-finder-spec.coffee | 20 ++++++++--------- spec/extensions/tree-view-spec.coffee | 12 +++++------ src/app/editor.coffee | 5 +++-- src/app/root-view.coffee | 6 +++--- src/app/status-bar.coffee | 2 +- src/extensions/autocomplete/index.coffee | 2 +- src/extensions/command-panel/index.coffee | 2 +- src/extensions/tree-view/tree-view.coffee | 2 +- 11 files changed, 42 insertions(+), 41 deletions(-) diff --git a/spec/app/atom-spec.coffee b/spec/app/atom-spec.coffee index 6967bc689..3c4b5ab21 100644 --- a/spec/app/atom-spec.coffee +++ b/spec/app/atom-spec.coffee @@ -27,7 +27,7 @@ describe "Atom", -> runs -> expect(atom.windows.length).toBe previousWindowCount + 1 newWindow = _.last(atom.windows) - expect(newWindow.rootView.getActiveEditor().getBuffer().getPath()).toEqual filePath + expect(newWindow.rootView.getActiveEditor().getPath()).toEqual filePath expect(newWindow.rootView.getActiveEditor().getBuffer().getText()).toEqual fs.read(filePath) describe ".windowOpened(window)", -> diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 7a8c8b5f0..421984e7f 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -260,7 +260,7 @@ describe "Editor", -> editor = rootView.getActiveEditor() project = rootView.project - expect(editor.getBuffer().getPath()).toBe tempFilePath + expect(editor.getPath()).toBe tempFilePath afterEach -> expect(fs.remove(tempFilePath)) @@ -279,7 +279,7 @@ describe "Editor", -> beforeEach -> editor.edit(rootView.project.open()) - expect(editor.getBuffer().getPath()).toBeUndefined() + expect(editor.getPath()).toBeUndefined() editor.getBuffer().setText 'Save me to a new path' spyOn($native, 'saveDialog').andCallFake -> selectedFilePath diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 4ad92fb3d..160be2e4a 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -25,7 +25,7 @@ describe "RootView", -> expect(rootView.project.getPath()).toBe fs.directory(path) expect(rootView.getEditors().length).toBe 1 expect(rootView.getEditors()[0]).toHaveClass 'active' - expect(rootView.getActiveEditor().getBuffer().getPath()).toBe path + expect(rootView.getActiveEditor().getPath()).toBe path expect(rootView.getActiveEditor().editSessions.length).toBe 1 expect(document.title).toBe path @@ -95,11 +95,11 @@ describe "RootView", -> editor2 = rootView.panes.find('.row > .column > .pane .editor:eq(0)').view() editor4 = rootView.panes.find('.row > .column > .pane .editor:eq(1)').view() - expect(editor1.getBuffer().getPath()).toBe require.resolve('fixtures/dir/a') - expect(editor2.getBuffer().getPath()).toBe require.resolve('fixtures/dir/b') - expect(editor3.getBuffer().getPath()).toBe require.resolve('fixtures/sample.js') + expect(editor1.getPath()).toBe require.resolve('fixtures/dir/a') + expect(editor2.getPath()).toBe require.resolve('fixtures/dir/b') + expect(editor3.getPath()).toBe require.resolve('fixtures/sample.js') expect(editor3.getCursorScreenPosition()).toEqual [2, 3] - expect(editor4.getBuffer().getPath()).toBe require.resolve('fixtures/sample.txt') + expect(editor4.getPath()).toBe require.resolve('fixtures/sample.txt') expect(editor4.getCursorScreenPosition()).toEqual [0, 2] # ensure adjust pane dimensions is called @@ -114,7 +114,7 @@ describe "RootView", -> expect(editor3.isFocused).toBeFalsy() expect(editor4.isFocused).toBeFalsy() - expect(document.title).toBe editor2.getBuffer().getPath() + expect(document.title).toBe editor2.getPath() describe "when called with no pathToOpen", -> it "opens no buffer", -> @@ -529,13 +529,13 @@ describe "RootView", -> it "opens an empty buffer in a new editor", -> rootView.open() expect(rootView.getActiveEditor()).toBeDefined() - expect(rootView.getActiveEditor().getBuffer().getPath()).toBeUndefined() + expect(rootView.getActiveEditor().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.getActiveEditor()).toBeDefined() - expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/dir/b') + expect(rootView.getActiveEditor().getPath()).toBe require.resolve('fixtures/dir/b') describe "when there is an active editor", -> beforeEach -> @@ -544,7 +544,7 @@ describe "RootView", -> describe "when called with no path", -> it "opens an empty buffer in the active editor", -> rootView.open() - expect(rootView.getActiveEditor().getBuffer().getPath()).toBeUndefined() + expect(rootView.getActiveEditor().getPath()).toBeUndefined() describe "when called with a path", -> [editor1, editor2] = [] @@ -563,7 +563,7 @@ describe "RootView", -> describe "when the active editor has an edit session for the given path", -> it "re-activates the existing edit session", -> - expect(activeEditor.getBuffer().getPath()).toBe require.resolve('fixtures/dir/a') + expect(activeEditor.getPath()).toBe require.resolve('fixtures/dir/a') previousEditSession = activeEditor.activeEditSession rootView.open('b') @@ -581,7 +581,7 @@ describe "RootView", -> 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.getActiveEditor() - expect(activeEditor.getBuffer().getPath()).toBe require.resolve('fixtures/dir/a') + expect(activeEditor.getPath()).toBe require.resolve('fixtures/dir/a') previousEditSession = activeEditor.activeEditSession rootView.open('b') @@ -596,11 +596,11 @@ describe "RootView", -> expect(rootView.getActiveEditor()).toBe editor1 rootView.open('b', allowActiveEditorChange: true) expect(rootView.getActiveEditor()).toBe editor2 - expect(editor2.getBuffer().getPath()).toBe require.resolve('fixtures/dir/b') + expect(editor2.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.getActiveEditor()).toBe editor1 - expect(editor1.getBuffer().getPath()).toBe path + expect(editor1.getPath()).toBe path diff --git a/spec/extensions/fuzzy-finder-spec.coffee b/spec/extensions/fuzzy-finder-spec.coffee index 90bc6dd3c..fb5c1a999 100644 --- a/spec/extensions/fuzzy-finder-spec.coffee +++ b/spec/extensions/fuzzy-finder-spec.coffee @@ -71,14 +71,14 @@ describe 'FuzzyFinder', -> selectedLi = finder.find('li:eq(1)') expectedPath = rootView.project.resolve(selectedLi.text()) - expect(editor1.getBuffer().getPath()).not.toBe expectedPath - expect(editor2.getBuffer().getPath()).not.toBe expectedPath + expect(editor1.getPath()).not.toBe expectedPath + expect(editor2.getPath()).not.toBe expectedPath finder.trigger 'fuzzy-finder:select-path' expect(finder.hasParent()).toBeFalsy() - expect(editor1.getBuffer().getPath()).not.toBe expectedPath - expect(editor2.getBuffer().getPath()).toBe expectedPath + expect(editor1.getPath()).not.toBe expectedPath + expect(editor2.getPath()).toBe expectedPath expect(editor2.isFocused).toBeTruthy() describe "when no paths are highlighted", -> @@ -159,8 +159,8 @@ describe 'FuzzyFinder', -> finder.trigger 'fuzzy-finder:select-path' expect(finder.hasParent()).toBeFalsy() - expect(editor1.getBuffer().getPath()).not.toBe expectedPath - expect(editor2.getBuffer().getPath()).toBe expectedPath + expect(editor1.getPath()).not.toBe expectedPath + expect(editor2.getPath()).toBe expectedPath expect(editor2.isFocused).toBeTruthy() describe "when the highlighted path is not open in the active editor, but instead is open on another editor", -> @@ -179,8 +179,8 @@ describe 'FuzzyFinder', -> finder.trigger 'fuzzy-finder:select-path' expect(finder.hasParent()).toBeFalsy() - expect(editor1.getBuffer().getPath()).not.toBe expectedPath - expect(editor2.getBuffer().getPath()).toBe expectedPath + expect(editor1.getPath()).not.toBe expectedPath + expect(editor2.getPath()).toBe expectedPath expect(editor2.isFocused).toBeTruthy() describe "common behavior between file and buffer finder", -> @@ -271,12 +271,12 @@ describe 'FuzzyFinder', -> selectedLi = finder.find('li:eq(1)') expectedPath = rootView.project.resolve(selectedLi.text()) - expect(rootView.getActiveEditor().getBuffer().getPath()).not.toBe expectedPath + expect(rootView.getActiveEditor().getPath()).not.toBe expectedPath expect(rootView.getActiveEditor().isFocused).toBeFalsy() selectedLi.mousedown() - expect(rootView.getActiveEditor().getBuffer().getPath()).toBe expectedPath + expect(rootView.getActiveEditor().getPath()).toBe expectedPath expect(rootView.getActiveEditor().isFocused).toBeTruthy() describe ".findMatches(queryString)", -> diff --git a/spec/extensions/tree-view-spec.coffee b/spec/extensions/tree-view-spec.coffee index 2dd302f6e..12aa90cd1 100644 --- a/spec/extensions/tree-view-spec.coffee +++ b/spec/extensions/tree-view-spec.coffee @@ -171,20 +171,20 @@ describe "TreeView", -> sampleJs.trigger clickEvent(originalEvent: { detail: 1 }) expect(sampleJs).toHaveClass 'selected' - expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js') + expect(rootView.getActiveEditor().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.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.txt') + expect(rootView.getActiveEditor().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.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js') + expect(rootView.getActiveEditor().getPath()).toBe require.resolve('fixtures/sample.js') expect(rootView.getActiveEditor().isFocused).toBeFalsy() sampleJs.trigger clickEvent(originalEvent: { detail: 2 }) @@ -386,7 +386,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.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js') + expect(rootView.getActiveEditor().getPath()).toBe require.resolve('fixtures/sample.js') describe "when a directory is selected", -> it "expands or collapses the directory", -> @@ -465,7 +465,7 @@ describe "TreeView", -> expect(fs.exists(newPath)).toBeTruthy() expect(fs.isFile(newPath)).toBeTruthy() expect(addDialog.parent()).not.toExist() - expect(rootView.getActiveEditor().getBuffer().getPath()).toBe newPath + expect(rootView.getActiveEditor().getPath()).toBe newPath waitsFor "tree view to be updated", -> dirView.entries.find("> .file").length > 1 @@ -494,7 +494,7 @@ describe "TreeView", -> expect(fs.exists(newPath)).toBeTruthy() expect(fs.isDirectory(newPath)).toBeTruthy() expect(addDialog.parent()).not.toExist() - expect(rootView.getActiveEditor().getBuffer().getPath()).not.toBe newPath + expect(rootView.getActiveEditor().getPath()).not.toBe newPath describe "when a file or directory already exists at the given path", -> it "shows an error message and does not close the dialog", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index ecfc34465..7d7946fcd 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -247,6 +247,7 @@ class Editor extends View setText: (text) -> @getBuffer().setText(text) getText: -> @getBuffer().getText() + getPath: -> @getBuffer().getPath() getLastBufferRow: -> @getBuffer().getLastRow() getTextInRange: (range) -> @getBuffer().getTextInRange(range) getEofPosition: -> @getBuffer().getEofPosition() @@ -498,7 +499,7 @@ class Editor extends View $(window).off 'resize', @_setSoftWrapColumn save: -> - if not @getBuffer().getPath() + if not @getPath() path = Native.saveDialog() return false if not path @getBuffer().saveAs(path) @@ -539,7 +540,7 @@ class Editor extends View close: -> return if @mini if @getBuffer().isModified() - filename = if @getBuffer().getPath() then fs.base(@getBuffer().getPath()) else "untitled buffer" + filename = if @getPath() then fs.base(@getPath()) else "untitled buffer" message = "'#{filename}' has changes, do you want to save them?" detailedMessage = "Your changes will be lost if you don't save them" buttons = [ diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index eae2428ee..8f42392f2 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -132,9 +132,9 @@ class RootView extends View if not editor.mini editor.on 'editor-path-change.root-view', => - @trigger 'active-editor-path-change', editor.getBuffer().getPath() - if not previousActiveEditor or editor.getBuffer().getPath() != previousActiveEditor.getBuffer().getPath() - @trigger 'active-editor-path-change', editor.getBuffer().getPath() + @trigger 'active-editor-path-change', editor.getPath() + if not previousActiveEditor or editor.getPath() != previousActiveEditor.getPath() + @trigger 'active-editor-path-change', editor.getPath() activeKeybindings: -> keymap.bindingsForElement(document.activeElement) diff --git a/src/app/status-bar.coffee b/src/app/status-bar.coffee index 40115df40..0894851b5 100644 --- a/src/app/status-bar.coffee +++ b/src/app/status-bar.coffee @@ -28,7 +28,7 @@ class StatusBar extends View @editor.on 'cursor-move', => @updateCursorPositionText() updatePathText: -> - path = @editor.getBuffer().getPath() + path = @editor.getPath() if path @currentPath.text(@rootView.project.relativize(path)) else diff --git a/src/extensions/autocomplete/index.coffee b/src/extensions/autocomplete/index.coffee index 6cf3142ba..4cee041e6 100644 --- a/src/extensions/autocomplete/index.coffee +++ b/src/extensions/autocomplete/index.coffee @@ -1 +1 @@ -module.exports = require 'autocomplete/autocomplete.coffee' \ No newline at end of file +module.exports = require 'autocomplete/autocomplete.coffee' diff --git a/src/extensions/command-panel/index.coffee b/src/extensions/command-panel/index.coffee index 761d95578..4d7dbb69f 100644 --- a/src/extensions/command-panel/index.coffee +++ b/src/extensions/command-panel/index.coffee @@ -1 +1 @@ -module.exports = require 'command-panel/command-panel' \ No newline at end of file +module.exports = require 'command-panel/command-panel' diff --git a/src/extensions/tree-view/tree-view.coffee b/src/extensions/tree-view/tree-view.coffee index ade0c9226..260dbaaf1 100644 --- a/src/extensions/tree-view/tree-view.coffee +++ b/src/extensions/tree-view/tree-view.coffee @@ -101,7 +101,7 @@ class TreeView extends View @append(@root) selectActiveFile: -> - activeFilePath = @rootView.getActiveEditor()?.getBuffer().getPath() + activeFilePath = @rootView.getActiveEditor()?.getPath() @selectEntryForPath(activeFilePath) selectEntryForPath: (path) ->