CodinGame / monaco-vscode-api

VSCode public API plugged on the monaco editor
MIT License
205 stars 29 forks source link

Error `Not allowed` when trying to create a file/folder in code and in the Demo app #447

Closed bosunski closed 1 week ago

bosunski commented 3 weeks ago

Hello there 👋🏽, Thanks for this excellent library!

I was trying out the Demo and tried renaming a file, specifically, the ones that aren't read-only (judging by the code). But I was getting the Not allowed error. I had initially tried this in code but encountered the error and thought I was probably doing something wrong, only to experience it in the Demo.

I did a little digging and could see this error is from the implementation of RegisteredFilesystemProvider which is also used in the Demo app.

Is there something I need to do to rename files/folders and perform other file operations?

Thanks!

CGNonofr commented 3 weeks ago

Hello!

That was... kind of a choice, the registeredFileSystemProvider contains static files.

What is your use-case?

If you want to let the user do whatever they want, you can instead write your file in the MemoryFileSystemProvider

CGNonofr commented 3 weeks ago

That feature did exist but was removed during a refactor because it was not that simple to implement. If you manage to convince me of a valid use-case, I may consider implementing it :)

bosunski commented 3 weeks ago

I don't know to what extent this use case is valid, so I might not be able to convince you 😅, but let me try.

I want a user to be able to do anything they want (rename, create, delete, etc) as in a standard IDE. I'm making a browser-based IDE where files are stored in a backend, and they are read/written over an API.

If you want to let the user do whatever they want, you can instead write your file in the MemoryFileSystemProvider

My understanding is that the MemoryFileSystemProvider requires that the contents of all files be known beforehand, since files are stored on a backend, this isn't desirable since there can be many files, and we'll need to read ALL of them. Do you think MemoryFileSystemProvider can still work for this use case, and how?

CGNonofr commented 3 weeks ago

I'm confused, are you creating a RegisteredFile for each remote file?

Then a better solution is probably to implement your own FileSystemProvider directly

bosunski commented 3 weeks ago

I'm confused, are you creating a RegisteredFile for each remote file?

Then a better solution is probably to implement your own FileSystemProvider directly

Yes, I create a RegisteredFile for each of the remote files.

bosunski commented 1 week ago

I am closing this because I went ahead and looked into your suggestion of implementing a custom provider. This is working well so far.

Thanks for your help and this library @CGNonofr .