diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 05e454da3..39740ebd2 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -163,14 +163,8 @@ describe "TextEditor", -> expect(editor.getTitle()).toBe 'untitled' describe ".getLongTitle()", -> - it "appends the name of the containing directory to the basename of the file", -> - expect(editor.getLongTitle()).toBe 'sample.js - fixtures' - buffer.setPath(undefined) - expect(editor.getLongTitle()).toBe 'untitled' - - describe ".getUniqueTitle()", -> it "returns file name when there is no opened file with identical name", -> - expect(editor.getUniqueTitle()).toBe 'sample.js' + expect(editor.getLongTitle()).toBe 'sample.js' buffer.setPath(undefined) expect(editor.getLongTitle()).toBe 'untitled' @@ -183,8 +177,8 @@ describe "TextEditor", -> atom.workspace.open(path.join('sample-theme-2', 'readme')).then (o) -> editor2 = o runs -> - expect(editor1.getUniqueTitle()).toBe 'sample-theme-1/readme' - expect(editor2.getUniqueTitle()).toBe 'sample-theme-2/readme' + expect(editor1.getLongTitle()).toBe 'sample-theme-1/readme' + expect(editor2.getLongTitle()).toBe 'sample-theme-2/readme' it "or returns /.../ when opened files has identical file names", -> editor1 = null @@ -195,8 +189,8 @@ describe "TextEditor", -> atom.workspace.open(path.join('sample-theme-2', 'src', 'js', 'main.js')).then (o) -> editor2 = o runs -> - expect(editor1.getUniqueTitle()).toBe 'sample-theme-1/.../main.js' - expect(editor2.getUniqueTitle()).toBe 'sample-theme-2/.../main.js' + expect(editor1.getLongTitle()).toBe 'sample-theme-1/.../main.js' + expect(editor2.getLongTitle()).toBe 'sample-theme-2/.../main.js' it "notifies ::onDidChangeTitle observers when the underlying buffer path changes", -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index e5b3bd481..29d56c6c8 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -586,18 +586,18 @@ class TextEditor extends Model else 'untitled' - # Essential: Get unique title for display in other parts of the UI - # such as the window title. + # Essential: Get unique title for display in other parts of the UI, such as + # the window title. # # If the editor's buffer is unsaved, its title is "untitled" # If the editor's buffer is saved, its unique title is formatted as one # of the following, # * "" when it is the only editing buffer with this file name. # * "/.../", where the "..." may be omitted - # if the the direct parent directory is already different. + # if the the direct parent directory is already different. # # Returns a {String} - getUniqueTitle: -> + getLongTitle: -> if sessionPath = @getPath() title = @getTitle() @@ -625,22 +625,6 @@ class TextEditor extends Model else 'untitled' - # Essential: Get the editor's long title for display in other parts of the UI - # such as the window title. - # - # If the editor's buffer is saved, its long title is formatted as - # " - ". If it is unsaved, its title is "untitled" - # - # Returns a {String}. - getLongTitle: -> - if sessionPath = @getPath() - fileName = path.basename(sessionPath) - directory = @project.relativize(path.dirname(sessionPath)) - directory = if directory.length > 0 then directory else path.basename(path.dirname(sessionPath)) - "#{fileName} - #{directory}" - else - 'untitled' - # Essential: Returns the {String} path of this editor's text buffer. getPath: -> @buffer.getPath()