Code-server: Programatically Set Folder to Open

Created on 28 Jun 2019  Â·  13Comments  Â·  Source: cdr/code-server

Here is my case. I'm on mysite.com and I wanna redirect my user to code-server URL in new tab but I want that user to be landed on a particular directory. This is the same as we do with file > Open folder. but I need it to be done programatically.

Is there any way to achieve this?

CC: @deansheather

question

Most helpful comment

Isn't it a good and quick feature to add in code-server to read query parameter let's say path and set the landing directory.

All 13 comments

@code-asher @nhooyr @kylecarbs @sr229 Any kind words on this issue would be appreciated.

Or can you people please add some functionality to pass required directory path in query parameters. And by using those parameters code-server automatically change opened folder.

When should I expect any response on this?

At the moment I don't think we support changing the project directory programmatically. You might be able to write an extension for this or create a proxy that relaunches code-server in the correct directory.

Any idea on how proxy would work in my scenario would be really helpful. But actually I don't wanna relaunch code-server everytime.

This isn't a very robust solution, but the proxy would just look at the URL query parameters to check which folder it should be using, then just relaunch code-server when the query parameters change.

Isn't it a good and quick feature to add in code-server to read query parameter let's say path and set the landing directory.

@abubakar-bilal hi, how to set default folder for landing ? That will meet my needs.

@xmpilot there is no such coded feature yet in code-server.

@sr229 thanks your feedback, i got the solution by vs code.

@xmpilot - Can you past here the solution? Need a similar thing!

@xmpilot - Can you past here the solution? Need a similar thing!
i changed the vs code as below file,that is no good solution,but it is meed my need only,
1.set default open file:
./lib/vscode/src/vs/platform/workspace/common/workspace.ts (line.186)
change return value of getFolder function.
2.set default open folder:
./lib/vscode/src/vs/workbench/browser/parts/editor/editorGroupView.ts(line.135)
from.editors = [editor];

Once https://github.com/cdr/code-server/pull/857 is merged you can have a folder query parameter which will make code-server open in that directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

broady picture broady  Â·  3Comments

rcarmo picture rcarmo  Â·  3Comments

lshamis picture lshamis  Â·  3Comments

nol166 picture nol166  Â·  3Comments

pchecinski picture pchecinski  Â·  3Comments