Merge branch 'searchfixes' of https://github.com/ethereum/remix-project into searchfixes

pull/2170/head
filip mertens 3 years ago
commit db7222e3cc
  1. 8
      apps/remix-ide/src/app/files/fileManager.ts
  2. 9
      apps/remix-ide/src/app/files/fileProvider.js
  3. 8
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  4. 9
      apps/remix-ide/src/app/panels/tab-proxy.js

@ -272,7 +272,13 @@ class FileManager extends Plugin {
await this._handleIsDir(src, `Cannot copy from ${src}. Path is not a directory.`)
await this._handleExists(dest, `Cannot paste content into ${dest}. Path does not exist.`)
await this._handleIsDir(dest, `Cannot paste content into ${dest}. Path is not directory.`)
await this.inDepthCopy(src, dest)
const provider = this.fileProviderOf(src)
if (provider.isSubDirectory(src, dest)) {
this.call('notification', 'toast', 'File(s) to paste is an ancestor of the destination folder')
} else {
await this.inDepthCopy(src, dest)
}
} catch (e) {
throw new Error(e)
}

@ -3,6 +3,7 @@
import { CompilerImports } from '@remix-project/core-plugin'
const EventManager = require('events')
const remixLib = require('@remix-project/remix-lib')
const pathModule = require('path')
const Storage = remixLib.Storage
class FileProvider {
@ -308,6 +309,14 @@ class FileProvider {
_normalizePath (path) {
return this.type + path
}
isSubDirectory (parent, child) {
if (!parent) return false
if (parent === child) return true
const relative = pathModule.relative(parent, child)
return !!relative && relative.split(pathModule.sep)[0] !== '..'
}
}
module.exports = FileProvider

@ -49,14 +49,6 @@ class WorkspaceFileProvider extends FileProvider {
return ret
}
isSubDirectory (parent, child) {
if (!parent) return false
if (parent === child) return true
const relative = pathModule.relative(parent, child)
return !!relative && relative.split(pathModule.sep)[0] !== '..'
}
resolveDirectory (path, callback) {
super.resolveDirectory(path, (error, files) => {
if (error) return callback(error)

@ -190,15 +190,6 @@ export class TabProxy extends Plugin {
}
renameTab (oldName, newName) {
this.addTab(newName, '', async () => {
await this.fileManager.open(newName)
this.event.emit('openFile', newName)
},
async () => {
await this.fileManager.closeFile(newName)
this.event.emit('closeFile', newName)
this.emit('closeFile', newName)
})
this.removeTab(oldName)
}

Loading…
Cancel
Save