mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add active path and file name to atom-pane
This commit is contained in:
@@ -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", ->
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user