mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Merge branch 'beta'
This commit is contained in:
@@ -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 <parent-directory>/.../<filename> 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", ->
|
||||
|
||||
@@ -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,
|
||||
# * "<filename>" when it is the only editing buffer with this file name.
|
||||
# * "<unique-dir-prefix>/.../<filename>", 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
|
||||
# "<filename> - <directory>". 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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user