-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running Code should open a new instance, not activate a currently opened one #48
Comments
+1 |
Agreed, this is one of the main annoyances of code. I don't know any other editor that behaves the way code does. The default should be new window with an optional flag to reuse if you really want that behavior. |
You can use the command line option |
This is good. But there's no way to make it a default option? |
Fair, I can see about an option. |
👍 for multiple instances, but I wanted to provide this workaround in the meantime: # linux (assuming you symlinked already)
code () { /usr/local/bin/code -n $* }
# osx
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* } |
Does someone have an idea how to name this setting? The intent is to control if launching "code" without path arguments will focus the last active instance or open a new, empty instance. |
|
Our settings typically follow this pattern |
|
Well thats good but does not really capture the case that we only do so if you are passing in no arguments. I thought about |
Do/can the settings have descriptions to go along with them? Adding |
When I select File | Preferences | User Settings, type However, on Windows 10.0.10586.36 in Code 0.10.6, typing The setting In addition, Combined, this means I cannot open more than one instance of code except through File Exporer and I cannot use code from the command prompt in a meaningful way which I used to do a lot. Could this be an upgrade issue?
code.cmd is:
code.js is:
|
@ericwj The setting to force reopen files in new windows or not is called From the command line you can use Could it be that in your case a window is already opened on a specific folder you try to open and it just is not focussed? There is another issue on Windows 10 where Code is not able to order a window from the background to the foreground, which might be related. To make sure things work properly:
You should find 2 instances of code running. |
Assume I'm in Sure I tried with a folder that wasn't open already. I updated my comment while investigating, please reread. I'm convinced there is an issue with the opening of code through the command prompt. It points to .\bin\code.cmd which starts .\code.exe with .\bin\code.js as the first argument, which starts .\code.exe. That's too many steps to just do .\code.exe %* which is what the registry sais should happen. If I edit code.cmd to do just that, all is fine. So I suspect perhaps code.cmd and/or code.js were left from a previous install as is the path with points to .\bin not . and their contents break all command line switches, at least --help and -n don't do anything whatsoever as I confirmed. |
Although running code.exe --help doesn't do anything still apart from showing a new prompt with a newline after it. code.exe -n . works but also shows a newline after the prompt that appears (cursor is at an empty line at the left window border after) and correctly focuses the same window and brings it to the front when done twice. |
@ericwj not sure why you refer to "--help", we do not support such an argument! If you suspect a bad install, maybe try reinstalling from scratch after uninstall. I do not think we changed the code.cmd/code.js recently though. |
'maketasks' will create a task runner config if not already present. 'code -n .' opens the current directory in a new vscode window (except if one is already open on this computer, including in a different session, see microsoft/vscode#48).
Should this issue be closed? :) |
I still would love to have a new, empty VSC instance when I middle-click on the icon in the task panel (win10 and VSC already opened). |
no it should remain open. I'd REALLY like a solution for this. @mikelward's solution actually doesn't work.. |
@mosajjal I'm not saying that's the solution, I'm saying that's the steps to reproduce/desired behavior! |
@mikelward I know. I edited my comment to point out that's not the solution. Looked a bit confusing |
To meet my requirement I executed using sudo option on ubuntu.
for now is enough for me. of course I should dismiss the warning message about running as 'root' |
Hack worked vscode works via xrdp in Ubuntu MATE 16.04: make a backup first |
Would having a separate instance permit me to edit a file in one window and have the preview of the file update in the other window? My use case has me modifying documents in Markdown or whiteboarding in Graphviz, and sharing up the live previews in meetings. That works better if I can share up only the preview, and not the source code. |
Speaking only for myself, opening using Code is a great experience. Opening Code is a bad experience (using Windows). No workaround makes it better for various reasons. The "-n" command line is not scalable:
The window.openFilesInNewWindow=on option solves half the problem of opening files from Explorer, but adds the problem of forcing all File->Open commands to open files in new windows (not my own desire), in addition to not solving the "other problem above. Seeing as how this issue is from Nov 2015, I just want to update the issue for this year, 2018, that Windows Notepad still currently has a more sensible application activation experience: **opening the shortcut opens a new window, middle-click taskbar opens new window, and opening files from Explorer opens new windows, and File->Open does not open new windows. Not possible with Code. Opening Code is a primary user interface experience, and the configuration solutions presently don' t address this. I like all the configuration options but here, many new configurations need not be necessary, I would just like to request a single window.openJustActLikeWindows7NotepadCirca2009=true. All these other window.open* features are handy conveniences that are fun to have, but they miss the broader picture. Again, only speaking for myself. |
@bpasero Any chance you could provide the reasoning from the Code team as to why this hasn't been implemented yet? It seems like a highly desired feature and is a behavior that's relatively unique to Code. |
I am thinking about 2 changes to make this easier:
Feedback welcome, I think this would cover the scenarios outlined here (starting just code and how code behaves when opening files). The settings name is not ideal but was chosen to be similar to the other 2 settings we already have for files and folders. |
My use case is Would |
@mikelward as for opening the same folder in multiple windows, that one is not handled with my proposed change. We have #2686 specifically for that case. I did not touch the flags |
Closing as per #48 (comment) via #45322 |
Ubuntu 12.04, vscode 0.10.1
Currently when you run
Code
if there is an instances already running (or shift clicking the app icon in Windows/Ubuntu) it will activate the currently opened window. This should open a new instance, the same goes for opening a new instance ofCode
with a folder as an argument when an instance is already open.It's a very common use case for many developers to have multiple editors with the same folder open.
Repro:
Code
(open instance of vscode)Code
Expected:
A new instance of vscode is opened
Actual:
The current instance of vscode is activated
The text was updated successfully, but these errors were encountered: