Add active path and file name to atom-pane

This commit is contained in:
Machiste Quintana
2015-04-14 20:52:26 -04:00
parent 06c7ed98f9
commit 2b43f7d163
2 changed files with 12 additions and 3 deletions

View File

@@ -119,9 +119,12 @@ describe "PaneView", ->
expect(pane.itemViews.find('#view-2').length).toBe 1
describe "when the new activeItem implements ::getPath", ->
it "adds .has-file-path to the active item element", ->
it "adds its file path to the active pane", ->
paneModel.activateItem(editor1)
expect(pane.itemViews.find('atom-text-editor')).toHaveClass('has-file-path')
expect(pane).toHaveAttr('data-active-path')
it "adds its file name to the active pane", ->
paneModel.activateItem(editor1)
expect(pane).toHaveAttr('data-active-name')
describe "when an item is destroyed", ->
it "triggers the 'pane:item-removed' event with the item and its former index", ->

View File

@@ -71,7 +71,13 @@ class PaneElement extends HTMLElement
hasFocus = @hasFocus()
itemView = atom.views.getView(item)
itemView.classList.add('has-file-path') if item.getPath?
if itemPath = item.getPath?()
path = require 'path'
@dataset.activeName = path.basename(itemPath)
@dataset.activePath = itemPath
else
delete @dataset.activeName
delete @dataset.activePath
unless @itemViews.contains(itemView)
@itemViews.appendChild(itemView)