This addresses an issue when you rename a folder which has files which are open in tabs.
It would recreate the current opened file because it is current and saved when another file opened. You'd get duplicate files. Also tabs from the old folder would still be visible.
Now the behavior should be: tabs that belong to the folder renamed will be closed and replaced. No file will be focused.
Please test.
pull/903/head
bunsenstraat 4 years ago committed by GitHub
parent 06beece3b9
commit 2c1aed4e8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      apps/remix-ide/src/app/files/fileManager.js
  2. 32
      apps/remix-ide/src/app/panels/tab-proxy.js

@ -300,20 +300,16 @@ class FileManager extends Plugin {
}
this.openFile(newName)
} else {
var newFocus
for (var k in this.openedFiles) {
if (k.indexOf(oldName + '/') === 0) {
var newAbsolutePath = k.replace(oldName, newName)
this.openedFiles[newAbsolutePath] = newAbsolutePath
delete this.openedFiles[k]
if (this._deps.config.get('currentFile') === k) {
newFocus = newAbsolutePath
this._deps.config.set('currentFile', '')
}
}
}
if (newFocus) {
this.openFile(newFocus)
}
}
// TODO: Only keep `this.emit` (issue#2210)
this.emit('fileRenamed', oldName, newName, isFolder)

@ -60,17 +60,17 @@ export class TabProxy extends Plugin {
})
fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => {
if (isFolder) return
if (isFolder) {
for (const tab of this.loadedTabs) {
if (tab.name.indexOf(oldName + '/') === 0) {
const newTabName = newName + tab.name.slice(oldName.length, tab.name.length)
this.renameTab(tab.name, newTabName)
}
}
return
}
// should change the tab title too
this.addTab(newName, '', () => {
this.fileManager.open(newName)
this.event.emit('openFile', newName)
},
() => {
this.fileManager.closeFile(newName)
this.event.emit('closeFile', newName)
})
this.removeTab(oldName)
this.renameTab(oldName, newName)
})
appManager.event.on('activate', ({ name, location, displayName, icon }) => {
@ -144,6 +144,18 @@ export class TabProxy extends Plugin {
}
}
renameTab (oldName, newName) {
this.addTab(newName, '', () => {
this.fileManager.open(newName)
this.event.emit('openFile', newName)
},
() => {
this.fileManager.closeFile(newName)
this.event.emit('closeFile', newName)
})
this.removeTab(oldName)
}
addTab (name, title, switchTo, close, icon) {
if (this._handlers[name]) return

Loading…
Cancel
Save