fix fileexplorer selected file

pull/3094/head
yann300 6 years ago
parent acdfefb5ad
commit 96e252c93a
  1. 27
      src/app/files/file-explorer.js

@ -79,8 +79,8 @@ function fileExplorer (localRegistry, files) {
self.focusElement = self.treeView.labelAt(self.focusPath) self.focusElement = self.treeView.labelAt(self.focusPath)
// TODO: here we update the selected file (it applicable) // TODO: here we update the selected file (it applicable)
// cause we are refreshing the interface of the whole directory when there's a new file. // cause we are refreshing the interface of the whole directory when there's a new file.
if (self.focusElement && !self.focusElement.classList.contains('bg-primary')) { if (self.focusElement && !self.focusElement.classList.contains('bg-secondary')) {
self.focusElement.classList.add('bg-primary') self.focusElement.classList.add('bg-secondary')
} }
}) })
} }
@ -165,17 +165,7 @@ function fileExplorer (localRegistry, files) {
}) })
self.treeView.event.register('leafClick', function (key, data, label) { self.treeView.event.register('leafClick', function (key, data, label) {
if (self.focusElement) { self.events.trigger('focus', [key])
self.focusElement.classList.remove('bg-secondary')
self.focusElement = null
self.focusPath = null
}
self.focusElement = self.treeView.labelAt(key)
if (self.focusElement) {
self.focusElement.classList.add('bg-secondary')
self.focusPath = key
self.events.trigger('focus', [key])
}
}) })
self.treeView.event.register('nodeClick', function (path, childrenContainer) { self.treeView.event.register('nodeClick', function (path, childrenContainer) {
@ -202,11 +192,18 @@ function fileExplorer (localRegistry, files) {
// register to main app, trigger when the current file in the editor changed // register to main app, trigger when the current file in the editor changed
self._deps.fileManager.events.on('currentFileChanged', (newFile) => { self._deps.fileManager.events.on('currentFileChanged', (newFile) => {
const explorer = self._deps.fileManager.fileProviderOf(newFile) const explorer = self._deps.fileManager.fileProviderOf(newFile)
if (self.focusElement && (!explorer || explorer.type !== files.type) && self.focusPath !== newFile) { if (self.focusElement && self.focusPath !== newFile) {
self.focusElement.classList.remove('bg-primary') self.focusElement.classList.remove('bg-secondary')
self.focusElement = null self.focusElement = null
self.focusPath = null self.focusPath = null
} }
if (explorer && (explorer.type === files.type)) {
self.focusElement = self.treeView.labelAt(newFile)
if (self.focusElement) {
self.focusElement.classList.add('bg-secondary')
self.focusPath = newFile
}
}
}) })
var textUnderEdit = null var textUnderEdit = null

Loading…
Cancel
Save