Is there any way to disable GitHub Copilot comment suggestions? - github

I really like Copilot however its comment suggestions can be nonsensical and really distracting.
Is there any way to leave the code suggestions on but turn Copilot off whenever I'm editing/adding a comment amidst the code?

I was annoyed at this too, and failed to find a decent automated solution anywhere on the web. So, I wrote a VSCode extension that watches the TextMate scopes wherever your active selection is, and if it detects a scope that contains comment, temporarily disables Copilot's inline suggestions until your caret is anywhere without a scope that contains comment.
Or, in short, it makes Copilot get out of your way whenever you're writing a comment, and lets it do its magic everywhere else.
Hopefully you can find some use for it as well.
https://marketplace.visualstudio.com/items?itemName=disable-copilot-comment-completions.disable-copilot-comment-completions

Here's a workaround I figured out for how to fix the comment suggestions problem! 🚀
The basic idea is to create a keyboard shortcut that we press in order to disable the inline suggestions from popping up. So before we write a comment, we can just press the keyboard shortcut to disable suggestions, then write the comment, and then press the keyboard shortcut to enable suggestions again. It's not a perfect solution, but it works!
To do this:
Install the Toggle extension.
(It's written by a vscode contributor and enables you to toggle settings with keyboard shortcuts. We need to do this because the Copilot extension doesn't actually provide a keyboard shortcut to disable inline suggestions.)
To your keybindings file for vscode, add the keyboard shortcut snippet below. You only need to change the values for key in order to have it work. (As of the time this comment was written, github.copilot.inlineSuggest.enable is the setting we need to toggle here. If they ever change that setting name in the future you'd have to change the below snippet accordingly.)
{
"key": "shift+cmd+c", // set this to whatever works for you
"command": "toggle",
// By the way, this "when" expression was inspired from the "when" expression for Copilot
// extension's "Trigger Inline Suggestions" keyboard shortcut.
"when": "editorTextFocus && !editorHasSelection",
"args": {
// This id is just a unique name you come up with yourself
"id": "toggleGithubCopilotInlineSuggestionsBeingEnabled",
// The names and values of the setting you want to toggle. In this case, it's to enable/disable the
// `github.copilot.inlineSuggest.enable` setting.
"value": [
{
"github.copilot.inlineSuggest.enable": true
},
{
"github.copilot.inlineSuggest.enable": false
}
]
}
},
For more info on how to setup a toggle keyboard shortcut you can look at the extension page for the Toggle extension. You can also read more info about it here.
Press the keyboard shortcut you set up and notice that the corresponding setting in vscode's settings file changes in response. Cool, you're done!
Note: This will allow you to disable inline suggestions from showing up. But it won't make a current inline suggestion, that's already showing, vanish. Just press Esc in that situation if it ever comes up. Ideally, you'd disable inline suggestions ahead of time before they'll pop up. That way you'll never have to press Esc.

Related

VSCode - Disable selection on auto-complete suggestion

Whenever I use autocomplete, VSCode automatically puts whatever I type in a selection, it didn't happen before and it only started happening recently.
Here's what happens:
I type something like this and suggestion comes up:
Then I press enter to auto complete:
All of this is fine, but when I start typing in the quotes:
VSCode automatically puts my text in a selection. This causes multiple problems. Suggestions get disabled in selection and I have to press Esc everytime I want the selection disabled.
Is there any way to fix this?
The question was already answered by #Anton Solomin and #devanil. The issue is VS code auto-suggestion is not working when text is highlighted, because some of your code snippet is preventing quick suggestion by VS code.
So just tell VS code that don't disable quick suggestion if some snippets askes you to do it.
Go to VScode settings page, in settings search bar type editor.suggest.snippetsPreventQuickSuggestions
Uncheck Controls whether an active snippet prevents quick suggestion

While in Vs code snippet and using intellisense, tab key accepts intellisense suggestion but exits snippet. Can I stay in snippet mode?

I really searched to see if others had this issue, but the suggestion was to remove "tab" from the keybindings.json file and the settings.json file. I've done that but it still behaves the same. When I am in "snippet" mode and normally can tab to the next snippet field, if I press Ctrl+space it will suggest text from intellisense. Then if I hit tab (the default accept suggestion trigger) I am then exited out of snippet mode and my tabs become regular tabs but does not switch to the next snippet variable field. I have a gist with my settings.json and my keybindings.json, but not sure if I'm allowed to post it here. Let me know if you need to look at the copy in my gist of those settings files.

Very disturbing pop up in Visual Studio Code

I don't know why, but since yesterday I have this kind of pop-up that follows my cursor when I write my code, it's SO disturbing! Does anyone know how to turn this stuff off? I had to accidentally activate it with a keyboard shortcut but no idea which one.
Open your settings, search for editor.parameterHints.enabled and untick the setting. Alternatively, in settings.json, add "editor.parameterHints.enabled": false (or set the key to false if it exists already).
You can still bring up the hints on demand using Ctrl+Shift+Space.

How to get keyboard shortcut `Cmd + S` to save on VS Code?

When I attempt to save my file on Visual Studio Code with the cmd+s keyboard shortcut, it does not save the code. I have to manually click File, the Save, just to be able to save my progress. I'm using macOS Catalina version 10.15.7 and VC Code version 1.55.2.
How do I fix this?
Attempts:
-Checked if ⌘ Cmd + S keyboard shortcut is tied to the Save functionality
If you do it right this solution will fix your issue.
I have never had a problem saving with VS-Code personally, but I have had issues with keybindings. IDK if you write your own keybindings, but if you do, you might want to check the keybindings that you have wrote to make sure they do not conflict with [CTRL + S]. The keybindings.json file that you create custom keybindings in, overrides the default keybindings.json file that defines the keybindings that VS-Code ships with.
To check your keybindings.json file...
Hit the F1-Key
A menu will drop open type in "Keyboard Shortcuts"
There will be two Preferences: Keyboard Shortcuts
Make sure to select Preferences: Keyboard Shortcuts and not Preferences: Default Keyboard Shortcuts
If the file is empty you are good. If you have keybindings written in the file, you need to iterate through them by hand, checking each one. Make sure that none use [CTRL + S] together. Even if the keybinding uses [CTRL + S] and other keys, you will need to disable it, so you can test if it is causing an issue.
Debugging [CTRL + S]
If your keybindings.json file is all good, then great, that's one thing to scratch off the list. The only thing left to do now is debug the Bound Key ("Key Binding"). To debug keybindings, you will use a built in tool, that VS-Code offers. To start do the following:
Hit the F1-Key
When the quick input drops open type the following into the text input:
"Toggle Keyboard Shortcuts Troubleshooting"
Select the option: Developer: Toggle Keyboard Shortcuts Troubleshooting
It should automatically open the OUTPUT panel, which is located in the same panel that your terminal is. Make sure that the OUTPUT is set to LOG(Window) in the drop down. (I took a picture and posted it below if you can't find the Keyboard Shortcut Troubleshooter).
The image might have funny declensions because I am on a dual monitor setup with 1 1080x1920 curved screen and one 1080x720 screen.... I cropped it to a STD HD 1920 width.
I Got My Trouble-shooter working, and Output open, now What Jay?
Okay... Well your at the right spot. Now every-time you press some keys, you should see your OUTPUT WINDOW working like crazy. It should be logging all sorts of stuff, which is good, very good.
This Part Is Important! READ CAREFULLY
What you want to do is use your keybinding that you feel isn't working appropriately. Use it when focus is set on an editor, use it when focus is set on a different editor, use it when focus is set on the sidebar. Where you are focused at in the editor at any given time can greatly affect a keybinding. The output is gonna write lines every-time you use your keybinding. Try not to hit any other keys while doing this, so you have a column in you output that includes logging from the keybinding you are testing only. Read the output see what it says. See if it looks right, or wrong. If it looks wrong, you can visit this link, to the VSCode site that covers this topic, and see if you can fix it your self. If you can't fix it your self, come back here, and edit your question. When you edit your question make sure that it includes the Troubleshooter's Logging Output.
VSCode Troubleshooting Keybindings (Keyboard Shortcuts) # https://code.visualstudio.com/docs/getstarted/keybindings#_troubleshooting-keybindings
Image that shows how to open the Keyboard Debugger
Also shows how to set the OUTPUT to Log(Window)
StackOverflow-2021-JUNE-26018:34-PST
Another thing to check for is, for lack of a better term, combination key bindings. For example, I was having an issue with ⌘+s. VSCode gave a message that it was waiting for the second key binding. After looking at the keybindings.json, I noticed I had a key binding for opening up user snippets as
{
"key": "cmd+s cmd+n",
"command": "workbench.action.openSnippets"
}
The ⌘+s portion of this key binding conflicted with the default ⌘+s

How to turn off the Quick Fix popup in VS Code

I am running VS Code 1.52.1 in Windows, editing JavaScript code. I am a double-click, copy & paste junkie. I mouse over something, like a function name, with the intent to double click copy it to the clipboard. But sometimes VS Code wants to suggest a "Quick Fix". This would be OK with me, except that the Quick Fix is displayed in a popup that overlays the code I am attempting to copy. Depending on how fast I am working, I may not notice until I paste the "old" contents of the clipboard into my target location.
Take the following function, for example.
// function to allow a promise-oriented caller to invoke
// a callback-oriented function
function callbackToPromise( resolve, reject ) {
return function done( err, data ) {
if(err) {
reject(err);
}
else {
resolve(data);
}
}
}
I mouse over the function name and the Quick Fix appears, overlaying the line of code where the mouse is hovering. The fix itself is redacted to avoid irrelevant discussion.
This behavior is both inconvenient and annoying, as it shifts my focus from the code to the misbehaving tool. It's like stubbing my toe a dozen times a day.
How can I configure VS Code not to automatically display Quick Fix popups? I would much prefer if VS Code would simply underline the function name and let me press the hotkey to see the popup.
I'm not aware of an exact/direct setting for the Quick Fix suggestion. What you can do though is to control the entire popup: increase the delay or disable it on mouse hover, then use shortcut keys to show it only when you want it to.
The settings for the mouse hover are editor.hover.*:
"editor.hover.delay": 300,
"editor.hover.enabled": true,
"editor.hover.sticky": true,
Set editor.hover.delay to some "high" value, so it gives you time to double-click to copy things before the popup appears. Or, disable it entirely with editor.hover.enabled.
As for the hotkeys, in Keyboard Shortcuts, there's editor.action.showHover:
You can disable the popup on mouse hover with editor.hover.enabled set to false, and then just use the shortcut key to show it manually (I'm using a Mac so it's showing Mac shortcut keys. There should also be one for Windows.)
From the popup, there's also a shortcut key for directly showing the Quick Fix suggestions. You can also configure that from Keyboard Shortcuts as editor.action.quickFix:
Again, you can disable the popup on mouse hover with editor.hover.enabled set to false and then just use the Quick Fix shortcut key to show it as needed.
In Windows 10 this is how I did it: Settings -> Text Editor -> Quick Suggestions Delay.