readd handling duplicate path

pull/1750/head
yann300 3 years ago committed by GitHub
parent 77abc0c21f
commit d9e6a8f663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      apps/remix-ide/src/app/panels/tab-proxy.js

@ -218,6 +218,7 @@ export class TabProxy extends Plugin {
if (index === -1) {
title = formatPath.join('/')
const titleLength = formatPath.length
this.loadedTabs.push({
id: name,
name,
@ -226,6 +227,25 @@ export class TabProxy extends Plugin {
tooltip: name,
iconClass: helper.getPathIcon(name)
})
formatPath.shift()
if (formatPath.length > 0) {
const index = this.loadedTabs.findIndex(({ title }) => title === formatPath.join('/'))
if (index > -1) {
const duplicateTabName = this.loadedTabs[index].name
const duplicateTabPath = duplicateTabName.split('/')
const duplicateTabFormatPath = [...duplicateTabPath].reverse()
const duplicateTabTitle = duplicateTabFormatPath.slice(0, titleLength).reverse().join('/')
this.loadedTabs[index] = {
id: duplicateTabName,
name: duplicateTabName,
title: duplicateTabTitle,
icon,
tooltip: duplicateTabName,
iconClass: helper.getPathIcon(duplicateTabName)
}
}
}
break
}
}

Loading…
Cancel
Save