From e916366c5be04b3887dccef74c5c26e2c52f3ab6 Mon Sep 17 00:00:00 2001 From: Oriol Mirosa Date: Thu, 8 Jun 2017 12:13:51 -0400 Subject: [PATCH] Added numbers to different panels in 'open files' panes --- CHANGELOG.md | 4 ++++ README.md | 3 ++- lib/open-files-pane-view.js | 1 + lib/open-files-view.js | 25 ++++++++++++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25ac3a7..230d3dd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.0 + +- When several panels are open, the title for the 'open files' panels now includes PANEL #, with the number showing the order in which the panels were opened. When panels are closed, the numbers of the panels are re-calculated so that they reflect the panels present in the workspace + ## 0.6.2 - Fixed a bug that threw an error whenever a new file was created after closing the 'Settings' page (mentioned in [#17](https://github.com/oriolmirosa/open-files/issues/17) diff --git a/README.md b/README.md index b1655a9..1c23a15 100755 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ This package is basically a fork of the [tree-view-open-files](https://atom.io/p * The cross to close a file only appears when the mouse hovers over the entry (while the 'edited' marker is always visible). * NEW in 0.6.0: In order to prevent the fast sliding down of the tree view when a file is added, there is a delay before the file appears in the 'open files' panel. The delay is configurable in the package's settings (default is 1000 ms, i.e., 1 second). * NEW in 0.6.0: Files added and removed from the 'open files' panel are animated. The animation has a default duration of 300 ms, but this is configurable in the package's settings (default is 300 ms). +* NEW in 0.7.0: When several panels are open, the title for the 'open files' panels now includes PANEL #, with the number showing the order in which the panels were opened. When panels are closed, the numbers of the panels are re-calculated so that they reflect the panels present in the workspace ## TODO -* Right now, when there are several panes in the editor, each one has its own 'open files' section in the tree-view, but they are all labeled 'open files'. The goal is for them to have a more descriptive label. +* Make the files in the 'open files' panel draggable, and keep the tab order in sync with the 'open files' order. * Configuration. Ideas and suggestions for further configuration options are welcome. diff --git a/lib/open-files-pane-view.js b/lib/open-files-pane-view.js index fd344e5..11d2925 100755 --- a/lib/open-files-pane-view.js +++ b/lib/open-files-pane-view.js @@ -19,6 +19,7 @@ export default class OpenFilesPaneView { this.container = document.createElement('ol') this.container.classList.add('list-tree') let header = document.createElement('div') + header.classList.add('open-files-title') atom.config.observe('open-files.collapsable', collapsable => { if (collapsable) { diff --git a/lib/open-files-view.js b/lib/open-files-view.js index eaeb570..4fa9761 100755 --- a/lib/open-files-view.js +++ b/lib/open-files-view.js @@ -56,7 +56,18 @@ export default class OpenFilesView { this.addTabGroup(pane) let destroySub = pane.onDidDestroy(() => { destroySub.dispose() - return this.removeTabGroup(pane) + this.removeTabGroup(pane) + setTimeout(() => { + if (atom.workspace.getCenter().getPanes().length === 1) { + let title = document.querySelector('.open-files-title') + title.innerHTML = 'OPEN FILES' + } else if (atom.workspace.getCenter().getPanes().length > 1) { + let titles = document.querySelectorAll('.open-files-title') + for (let i = 0; i < titles.length; i++) { + titles[i].innerHTML = 'PANEL #' + (i + 1) + ' - OPEN FILES' + } + } + }) }) return this.paneSub.add(destroySub) })) @@ -68,13 +79,21 @@ export default class OpenFilesView { let group = new OpenFilesPaneView group.setPane(pane, this.addIconToElement) this.groups.push(group) - return this.element.appendChild(group.element) + this.element.appendChild(group.element) + if (this.groups.length > 1) { + setTimeout(() => { + let titles = document.querySelectorAll('.open-files-title') + for (let i = 0; i < titles.length; i++) { + titles[i].innerHTML = 'PANEL #' + (i + 1) + ' - OPEN FILES' + } + }) + } } removeTabGroup(pane) { let group = _.findIndex(this.groups, group => group.pane === pane) this.groups[group].destroy() - return this.groups.splice(group, 1) + this.groups.splice(group, 1) } // Returns an object that can be retrieved when package is activated serialize() {}