Currently, when Theia gets started without a workspace dir, we are falling back to current working directory. This is almost ever what you want (maybe during development) and causes real issues with native Theia apps, because it open on root.
Therefore, we should change the behavior such that the workspace root is undefined if not provided and that the frontend will present the user with a dialog to choose a workspace root.
Updated:
These are the basic ideas we would like to achieve within the context of this task. Please note, although this is a cool feature, the current work is being done for #346 due to some performance issues.
Open... menu contribution or from the Select Workspace Root (whatever) button inside the Files navigator. Similar to VSCode. Unless the root is set, we do not show anything in the navigator, we do not have New File, New Folder, Open Terminal, and etc.. main or context menu contributions, keybindings. There is no layout restoration, no preferences. (Yes, that was our initial idea.)root to be undefined on the backend, still, we need some default, because we need to feed the workspace root selector dialog, but that is the only purpose of having a defaultRoot now.Later:
DefaultWorkspaceServer), after refreshing any window, the workspace root will be the one which was the most recently selected.We could just open theia and wait for the user to do open dir ?
I'm trying to avoid dialogs...
you can't do anything without a workspace, can you?
It should at least be obvious for the user what to do.
We could once more copy vscode, by adding a button in the navigator instead of the tree:

Sounds good.
It would be all nice to remove --root-dir option and just consider that a first arg to be a path if it is not option, similar what VS code does, e.g. code . to open the current dir.
It would be all nice to remove --root-dir option and just consider that a first arg to be a path if it is not option, similar what VS code does, e.g. code . to open the current dir.
I am a bit puzzled, the code is not the VSCode application itself, it is a script which is available from the path and launches the application with the given workspace root. Although I like the simplicity of this feature request, I think it is unrelated to this task. Can we split it up?
code on OS X:
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
function realpath() { /usr/bin/python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
code on Windows:
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
NAME="Code"
VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
ELECTRON="$VSCODE_PATH/$NAME.exe"
if grep -q Microsoft /proc/version; then
# If running under WSL don't pass cli.js to Electron as environment vars
# cannot be transferred from WSL to Windows
# See: https://github.com/Microsoft/BashOnWindows/issues/1363
# https://github.com/Microsoft/BashOnWindows/issues/1494
"$ELECTRON" "$@"
exit $?
fi
if [ "$(expr substr $(uname -s) 1 9)" == "CYGWIN_NT" ]; then
CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js")
else
CLI="$VSCODE_PATH/resources/app/out/cli.js"
fi
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
@kittaakos I think @svenefftinge already did it in https://github.com/theia-ide/theia/pull/612
Each service which depends on the workspace root should be able to gracefully handle the case when it is not yet available (undefined). ~Also, the WorkspaceServer should send an event to all listeners when the root has been changed (or set).~
PR: #615.
In your updated comments you forgo the idea to have the default root dir used for application that do not absolutely need a root dir like the terminal for example.. what @akosyakov refers to as tryRoot
I think this could be added now ? At least the base code for it... ?
In your updated comments you forgo the idea to have the default root dir used for application that do not absolutely need a root dir like the terminal for example
We did not plan to support this now, but I will definitely add it to the Later part. Thank you for the reminder!
Note I opened #657 #658 #656
About the issues raised for later.
Most helpful comment
It would be all nice to remove
--root-diroption and just consider that a first arg to be a path if it is not option, similar what VS code does, e.g.code .to open the current dir.