Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
9f9d1f4d
Commit
9f9d1f4d
authored
Aug 23, 2021
by
yann300
Committed by
Aniket
Aug 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolving external path for the "open" function was missing
parent
bed8feff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+29
-3
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
9f9d1f4d
...
@@ -170,6 +170,11 @@ class FileManager extends Plugin {
...
@@ -170,6 +170,11 @@ class FileManager extends Plugin {
async
open
(
path
)
{
async
open
(
path
)
{
try
{
try
{
path
=
this
.
limitPluginScope
(
path
)
path
=
this
.
limitPluginScope
(
path
)
try
{
path
=
this
.
_resolveFromExternalPath
(
path
).
file
||
path
}
catch
(
e
)
{
return
console
.
error
(
e
)
}
await
this
.
_handleExists
(
path
,
`Cannot open file
${
path
}
`
)
await
this
.
_handleExists
(
path
,
`Cannot open file
${
path
}
`
)
await
this
.
_handleIsFile
(
path
,
`Cannot open file
${
path
}
`
)
await
this
.
_handleIsFile
(
path
,
`Cannot open file
${
path
}
`
)
return
this
.
openFile
(
path
)
return
this
.
openFile
(
path
)
...
@@ -538,6 +543,22 @@ class FileManager extends Plugin {
...
@@ -538,6 +543,22 @@ class FileManager extends Plugin {
}
}
}
}
/**
* Try to resolve the given file path.
* e.g if it's specified a github link, npm library, or any external content,
* it returns the actual path where the content can be find.
* @param {string} file path we are trying to resolve
* @returns {{ string, provider }} file path resolved and its provider.
*/
_resolveFromExternalPath
(
file
)
{
const
provider
=
this
.
fileProviderOf
(
file
)
if
(
!
provider
)
throw
new
Error
(
`no provider for
${
file
}
`
)
return
{
file
:
provider
.
getPathFromUrl
(
file
)
||
file
,
// in case an external URL is given as input, we resolve it to the right internal path
provider
}
}
removeTabsOf
(
provider
)
{
removeTabsOf
(
provider
)
{
for
(
var
tab
in
this
.
openedFiles
)
{
for
(
var
tab
in
this
.
openedFiles
)
{
if
(
this
.
fileProviderOf
(
tab
).
type
===
provider
.
type
)
{
if
(
this
.
fileProviderOf
(
tab
).
type
===
provider
.
type
)
{
...
@@ -569,9 +590,14 @@ class FileManager extends Plugin {
...
@@ -569,9 +590,14 @@ class FileManager extends Plugin {
openFile
(
file
)
{
openFile
(
file
)
{
const
_openFile
=
(
file
)
=>
{
const
_openFile
=
(
file
)
=>
{
this
.
saveCurrentFile
()
this
.
saveCurrentFile
()
const
provider
=
this
.
fileProviderOf
(
file
)
let
resolved
if
(
!
provider
)
return
console
.
error
(
`no provider for
${
file
}
`
)
try
{
file
=
provider
.
getPathFromUrl
(
file
)
||
file
// in case an external URL is given as input, we resolve it to the right internal path
resolved
=
this
.
_resolveFromExternalPath
(
file
)
file
=
resolved
.
file
}
catch
(
e
)
{
return
console
.
error
(
e
)
}
const
provider
=
resolved
.
provider
this
.
_deps
.
config
.
set
(
'currentFile'
,
file
)
this
.
_deps
.
config
.
set
(
'currentFile'
,
file
)
this
.
openedFiles
[
file
]
=
file
this
.
openedFiles
[
file
]
=
file
provider
.
get
(
file
,
(
error
,
content
)
=>
{
provider
.
get
(
file
,
(
error
,
content
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment