Running code -n refocuses on the already open window.
It would make more sense for it to focus on the new window. This might just be an issue with how MacOS deals with new windows, I'm not able to test on Windows at the moment.
Steps to Reproduce:
Does this issue occur when all extensions are disabled?: Yes
-n, --new-window Force to open a new window.
-r, --reuse-window Force to open a file or folder in the last active window.
Maybe you should use -r instead of -n, if that's your intended behavior.
I think you're misunderstanding. I want to focus on the newly opened window so I can start typing in it immediately.
I see what you mean. Having Code Window A and running code -n to open Code Window B will not focus on the editor of B. Instead focus is given to A.
I can reproduce this.
@octref @Clockwork757 you can reproduce this? I would like too, but cannot. Here is what I do:
code -n"What are you doing differently?
@bpasero
code -nI have no idea when this broke or why this happens. If someone wants to chime in, feel free.
I wonder if this could possibly be related to macOS 10.13.4 update that came in recently. I can reproduce this behaviour in VS Code back to version 1.20, so I doubt this is a change we did that could explain this.
If anyone with a macOS version < 10.13.4 could try to reproduce this:
code -nHappens to me on 10.12.6.
Crazy... why did no-one report this before :-?
If someone wants to chime in and/or has an idea, feel free. Things I found out so far:
focus() the new window that is opening, the other one is still getting focusThis could be an upstream/electron issue, not sure yet.
I suspect this is a MacOS problem. I reproduced the same behavior with Chrome.
Sidenote: sorry for the closing and reopening. I think I'm instinctively hitting that as a cancel button😓
Interesting, I could not reproduce it with another app, but I also did not try Chrome, so it maybe related to Electron/Chrome.
I can definitely reproduce this reliably and it is only VSCode that has this issue. Chrome definitely does not.
also its worth noting that this is not a -n specific issue. it also fails to focus the new window when opening a director as a project by executing code ./some-directory
ive come across another side effect of this same issue.
https://github.com/microsoft/vscode/issues/80314
Any instance of a vscode window with a given directory open in it will take focus, regardless of the flags provided when attempting to open another window. in short, if you try to open dir foo twice but use the -n flag it wont even open a new window. also if you try to just open a second window it works fine if the window does not take a path as an argument, but even then trying to open the same dir foo in the newly opened window refocuses the old window.
@merveillevaneck See https://github.com/microsoft/vscode/issues/2686#issuecomment-441350180
@bpasero this shouldnt be an issue, because even though the shell prompt has a built in command for this, the documentation for the 'code' command makes it seem as though it can perform the required actions. however it doesnt. so either it should be included in the documentation or it should be changed to accommodate behavior.
thanks for pointing out the the duplicate command though. still would like to see this sort of thing resolved.
Feel free to provide a PR to change the documentation of the CLI program.
I still have this problem:
I open two projects all pointing to their own different directories.
I use the subl command to open a file within one of those directories.
It opens that file in whatever project window was last focused.
It should open each file in their corresponding project directory.
Should I open a new issue?
Thanks!
On Wed, Sep 4, 2019 at 8:02 AM Benjamin Pasero notifications@github.com
wrote:
Feel free to provide a PR to change the documentation of the CLI program.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/50793?email_source=notifications&email_token=AAACBQJCBIHSUD4ZJUXTDX3QH7EXHA5CNFSM4FCNN6M2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD533YYY#issuecomment-527940707,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAACBQOTGOU6ZSIHZ2BRZX3QH7EXHANCNFSM4FCNN6MQ
.
--
Jared
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Most helpful comment
@bpasero
code -n