Skip to content
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

Some keyboard shortcuts stop working when launching from terminal #71553

Closed
azdavis opened this issue Apr 1, 2019 · 15 comments
Closed

Some keyboard shortcuts stop working when launching from terminal #71553

azdavis opened this issue Apr 1, 2019 · 15 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X verified Verification succeeded

Comments

@azdavis
Copy link
Contributor

azdavis commented Apr 1, 2019

  • VSCode Version: Version: 1.33.0-insider, Commit: 4039ea8
  • OS Version: Darwin x64 18.5.0

Steps to Reproduce:

  1. Launch VSCode with no files
  2. Open a new file from a terminal (not VSCode's terminal; something like code file.txt)
  3. Try to use Add Next Occurrence (see below); it doesn't work (the menu bar just 'flashes')
  4. Move the focus away from VSCode (e.g. click on some other app), then back
  5. Try to use Add Next Occurrence; it does work

What I did to "try to use Add Next Occurrence":

  1. Type asdf
  2. Hit Command-D (the shortcut for Add Next Occurrence)
  3. Expect it to select asdf, it doesn't

A similar issue occurs with Copy Line Down. But the issue does not occur with Add Cursor Above or Add Cursor Below. I haven't tried other shortcuts.

The issues does not appear to happen if you skip step 1. But even if you skip step 1, it only doesn't happen for the first time.

What that means is: if VSCode is not running, and I launch it with code file.txt, then the shortcuts work in file.txt. But if I then do code other.txt, then the shortcuts do not work until I move the focus away and back as described.

Actually, the filename other.txt doesn't even have to be different from file.txt. So I can do code file.txt and the shortcuts will work, but then I can do code file.txt again and the shortcuts stop working.

Does this issue occur when all extensions are disabled?: Yes

@bpasero bpasero assigned alexdima and unassigned bpasero Apr 1, 2019
@alexdima alexdima added the macos Issues with VS Code on MAC/OS X label Apr 2, 2019
@alexdima
Copy link
Member

alexdima commented Apr 2, 2019

@azdavis I cannot reproduce on my mac. I launch code README.md for example and press cmd+d. This works immediately for me.

@alexdima alexdima added the info-needed Issue requires more information from poster label Apr 2, 2019
@azdavis
Copy link
Contributor Author

azdavis commented Apr 2, 2019

Hm. Was VSCode already running when you said code README.md? Also, from my testing the bug only seems to occur when the file does not already exist. When you tried it, did README.md already exist?

I can reliably reproduce this on my Mac; I can try to attach a screen recording if that might help.

@alexdima
Copy link
Member

alexdima commented Apr 2, 2019

@azdavis I could not reproduce even if the file does not exist. Have you by any chance customized your keybindings.json?

@azdavis
Copy link
Contributor Author

azdavis commented Apr 2, 2019

Here is my keybindings.json.

However, the problem persists even when I turn off the custom keybindings.

Here is a video of the problem.

@alexdima
Copy link
Member

alexdima commented Apr 3, 2019

Thank you, I could now reproduce.

@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Apr 3, 2019
@alexdima alexdima added this to the April 2019 milestone Apr 4, 2019
@alexdima alexdima modified the milestones: April 2019, May 2019 May 7, 2019
@iliyang
Copy link

iliyang commented May 7, 2019

I'm experiencing this problem when activating (an open instance of) VS Code via the URL scheme vscode:// from the Skim PDF viewer. This bug is an issue when working with LaTeX, where the URL-scheme activation is a very common task.

@alexdima alexdima modified the milestones: May 2019, On Deck May 24, 2019
@Dreen
Copy link

Dreen commented Jun 12, 2019

Can confirm this bug also occurs when using the "Semantic History" feature of iTerm2 Build 3.2.9 (Cmd+Click to open file).

However, there is a workaround that seems to work 100% for me; just right-click inside the document to bring out the context menu, then close that menu, and the key shortcuts should work.

@phaseOne
Copy link
Contributor

I ran into this exact issue today when attempting and failing to use the ⌘D "add next occurrence" keyboard shortcut. Calling the function from the menubar did work, so it's specifically an issue with the shortcut. I didn't open vscode from iTerm though. I already had it open, and then I opened an existing workspace from the Open Recent menu. I also had an integrated terminal open, but I hadn't interacted with it.

I used @Dreen's workaround to solve the issue. I haven't been able to reproduce yet.

  • VSCode Version 1.34.0
  • macOS Mojave 10.14.4 (18E226)

@Figbash
Copy link

Figbash commented Aug 5, 2019

This happens constantly if you use VSCode as an IDE for Unity 3D, every time you double to click a log to jump to the file/line in the code you can no longer use ⌘D until performing and canceling a find. It's nearly frustrating enough to switch IDEs if you use ⌘D a lot, if anyone could give this some attention that would be amazing.

@azdavis
Copy link
Contributor Author

azdavis commented Aug 11, 2019

This issue appears to happen also if you close an editor pane and dismiss unsaved changes.

Steps to reproduce:

  1. Open foo.txt, put something into it like foo
  2. Open bar.txt, put something in it like bar
  3. Save both
  4. Switch to bar.txt, make some changes
  5. Close bar.txt, hit Don't Save
  6. You should now be switched to foo.txt and the focus should be on the foo
  7. Try to use Cmd-D, it doesn't work

@alexdima
Copy link
Member

alexdima commented Sep 9, 2019

Looks like this one shares the same root cause as #79460

@bpasero bpasero added the info-needed Issue requires more information from poster label Sep 10, 2019
@bpasero bpasero removed this from the On Deck milestone Sep 10, 2019
@bpasero
Copy link
Member

bpasero commented Sep 10, 2019

@azdavis i
Can you try to reproduce with our nightly insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/

@bpasero bpasero removed the bug Issue identified by VS Code Team member as probable bug label Sep 10, 2019
@azdavis
Copy link
Contributor Author

azdavis commented Sep 10, 2019

I am still able to reproduce this issue, even on insiders.

@bpasero
Copy link
Member

bpasero commented Sep 10, 2019

@alexandrudima I am able to reproduce #71553 (comment) and here is what I observe so far:

  • it only reproduces with context key editorFocus but not editorTextFocus which indicates that the underlying issue is focus tracking
  • once the native dialog opens we correctly set context key editorFocus: false
  • once the native dialog closes, we do NOT restore context key editorFocus: true
  • as such, Cmd+D fails to work

Now, here is what I do in the workbench after the dialog closes:

  • the second (dirty) editor is not to be saved, so I close it
  • as such I reveal the first editor
  • this eventually calls into textAreaInput#_setHasFocus(true) (from here)
  • for some reason (and this is the bug actually), we think this._hasFocus === newHasFocus and return from that method without firing events

Can you please have a look as well.

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Sep 10, 2019
@bpasero bpasero added this to the September 2019 milestone Sep 10, 2019
@alexdima
Copy link
Member

👍 I've pushed a fix for the editorFocus context key not being set correctly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants