mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
When a directory view is collapsed, unwatch its directory and those of all descendant expanded directory views.
This commit is contained in:
@@ -3,7 +3,7 @@ RootView = require 'root-view'
|
||||
Directory = require 'directory'
|
||||
fs = require 'fs'
|
||||
|
||||
describe "TreeView", ->
|
||||
fdescribe "TreeView", ->
|
||||
[rootView, project, treeView, rootDirectoryView, sampleJs, sampleTxt] = []
|
||||
|
||||
beforeEach ->
|
||||
@@ -56,8 +56,9 @@ describe "TreeView", ->
|
||||
grandchild = child.find('.entries > li:contains(a-dir/)').view()
|
||||
grandchild.disclosureArrow.click()
|
||||
|
||||
rootDirectoryView.collapse()
|
||||
rootDirectoryView.expand()
|
||||
rootDirectoryView.disclosureArrow.click()
|
||||
expect(rootDirectoryView.find('.entries')).not.toExist()
|
||||
rootDirectoryView.disclosureArrow.click()
|
||||
|
||||
# previously expanded descendants remain expanded
|
||||
expect(rootDirectoryView.find('> .entries > li:contains(dir/) > .entries > li:contains(a-dir/) > .entries').length).toBe 1
|
||||
@@ -65,6 +66,23 @@ describe "TreeView", ->
|
||||
# collapsed descendants remain collapsed
|
||||
expect(rootDirectoryView.find('> .entries > li.contains(zed/) > .entries')).not.toExist()
|
||||
|
||||
it "when collapsing a directory, removes change subscriptions from the collapsed directory and its descendants", ->
|
||||
child = rootDirectoryView.entries.find('li:contains(dir/)').view()
|
||||
child.disclosureArrow.click()
|
||||
|
||||
grandchild = child.entries.find('li:contains(a-dir/)').view()
|
||||
grandchild.disclosureArrow.click()
|
||||
|
||||
expect(rootDirectoryView.directory.subscriptionCount()).toBe 1
|
||||
expect(child.directory.subscriptionCount()).toBe 1
|
||||
expect(grandchild.directory.subscriptionCount()).toBe 1
|
||||
|
||||
rootDirectoryView.disclosureArrow.click()
|
||||
|
||||
expect(rootDirectoryView.directory.subscriptionCount()).toBe 0
|
||||
expect(child.directory.subscriptionCount()).toBe 0
|
||||
expect(grandchild.directory.subscriptionCount()).toBe 0
|
||||
|
||||
describe "when a file is clicked", ->
|
||||
it "opens it in the active editor and selects it", ->
|
||||
expect(rootView.activeEditor()).toBeUndefined()
|
||||
|
||||
@@ -87,12 +87,6 @@ class DirectoryView extends View
|
||||
@expand() if isExpanded
|
||||
@disclosureArrow.on 'click', => @toggleExpansion()
|
||||
|
||||
_.defer =>
|
||||
@on 'DOMNodeRemoved', (e) =>
|
||||
if e.target == this[0] and @hasClass('expanded')
|
||||
console.log "unwatching!"
|
||||
@unwatchEntries()
|
||||
|
||||
buildEntries: ->
|
||||
@entries?.remove()
|
||||
@entries = $$ -> @ol class: 'entries'
|
||||
@@ -111,18 +105,19 @@ class DirectoryView extends View
|
||||
@addClass('expanded')
|
||||
@disclosureArrow.text('▾')
|
||||
@buildEntries()
|
||||
@watchEntries()
|
||||
@deserializeEntryExpansionStates(@entryStates) if @entryStates?
|
||||
@isExpanded = true
|
||||
@watchEntries()
|
||||
false
|
||||
|
||||
collapse: ->
|
||||
@entryStates = @serializeEntryExpansionStates()
|
||||
@removeClass('expanded')
|
||||
@disclosureArrow.text('▸')
|
||||
@unwatchEntries()
|
||||
@find('.expanded.directory').each -> $(this).view().unwatchEntries()
|
||||
@entries.remove()
|
||||
@entries = null
|
||||
@unwatchEntries()
|
||||
@isExpanded = false
|
||||
|
||||
watchEntries: ->
|
||||
|
||||
Reference in New Issue
Block a user