Add workspace name to tabs

pull/974/head
ioedeveloper 4 years ago
parent d1e7c4ee52
commit d7cdc6942f
  1. 7
      apps/remix-ide/src/app/files/fileManager.js
  2. 57
      apps/remix-ide/src/app/panels/tab-proxy.js

@ -610,6 +610,13 @@ class FileManager extends Plugin {
if (callback) callback(error) if (callback) callback(error)
}) })
} }
getCurrentWorkspace () {
const file = this.currentFile() || ''
const provider = this.fileProviderOf(file)
return provider.workspace
}
} }
module.exports = FileManager module.exports = FileManager

@ -38,19 +38,43 @@ export class TabProxy extends Plugin {
}) })
fileManager.events.on('fileRemoved', (name) => { fileManager.events.on('fileRemoved', (name) => {
this.removeTab(name) const workspace = this.fileManager.getCurrentWorkspace()
workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name)
}) })
fileManager.events.on('fileClosed', (name) => { fileManager.events.on('fileClosed', (name) => {
this.removeTab(name) const workspace = this.fileManager.getCurrentWorkspace()
workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name)
}) })
fileManager.events.on('currentFileChanged', (file) => { fileManager.events.on('currentFileChanged', (file) => {
if (this._handlers[file]) { const workspace = this.fileManager.getCurrentWorkspace()
this._view.filetabs.activateTab(file)
if (workspace) {
const workspacePath = workspace + '/' + file
if (this._handlers[workspacePath]) {
this._view.filetabs.activateTab(workspacePath)
return
}
this.addTab(workspacePath, '', () => {
this.fileManager.open(file)
this.event.emit('openFile', file)
},
() => {
this.fileManager.closeFile(file)
this.event.emit('closeFile', file)
})
} else {
const path = this.fileManager.mode + '/' + file
if (this._handlers[path]) {
this._view.filetabs.activateTab(path)
return return
} }
this.addTab(file, '', () => { this.addTab(path, '', () => {
this.fileManager.open(file) this.fileManager.open(file)
this.event.emit('openFile', file) this.event.emit('openFile', file)
}, },
@ -58,20 +82,37 @@ export class TabProxy extends Plugin {
this.fileManager.closeFile(file) this.fileManager.closeFile(file)
this.event.emit('closeFile', file) this.event.emit('closeFile', file)
}) })
}
}) })
fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => { fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => {
const workspace = this.fileManager.getCurrentWorkspace()
if (workspace) {
if (isFolder) { if (isFolder) {
for (const tab of this.loadedTabs) { for (const tab of this.loadedTabs) {
if (tab.name.indexOf(oldName + '/') === 0) { if (tab.name.indexOf(workspace + '/' + oldName + '/') === 0) {
const newTabName = newName + tab.name.slice(oldName.length, tab.name.length) const newTabName = workspace + '/' + newName + tab.name.slice(workspace + '/' + oldName.length, tab.name.length)
this.renameTab(tab.name, newTabName)
}
}
return
}
// should change the tab title too
this.renameTab(workspace + '/' + oldName, workspace + '/' + newName)
} else {
if (isFolder) {
for (const tab of this.loadedTabs) {
if (tab.name.indexOf(this.fileManager.mode + '/' + oldName + '/') === 0) {
const newTabName = this.fileManager.mode + '/' + newName + tab.name.slice(this.fileManager.mode + '/' + oldName.length, tab.name.length)
this.renameTab(tab.name, newTabName) this.renameTab(tab.name, newTabName)
} }
} }
return return
} }
// should change the tab title too // should change the tab title too
this.renameTab(oldName, newName) this.renameTab(this.fileManager.mode + '/' + oldName, workspace + '/' + newName)
}
}) })
appManager.event.on('activate', ({ name, location, displayName, icon }) => { appManager.event.on('activate', ({ name, location, displayName, icon }) => {

Loading…
Cancel
Save