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

Respect Inline Suggestion to improve compatibility with GitHub Copilot #1011

Closed
adam-coster opened this issue Sep 14, 2021 · 20 comments
Closed
Labels
Area: Input Related to editor input processing (key presses, key bindings). Issue: Bug Res: Fixed Fix is checked in, but it might be a few weeks until a release. Upstream Pertaining to an upstream component, or blocked by an upstream issue.
Milestone

Comments

@adam-coster
Copy link

adam-coster commented Sep 14, 2021

Issue: The inline suggestions provided by GitHub Copilot cannot be used in Markdown files while Markdown All In One is active.

Feature Request: Can we get a config option to toggle allowing Tab to take inline suggestions?

Update (@yzhang-gh): It has been fixed in the dev build.

Background & Workaround

I changed the markdown.extension.onTabKey keyboard shortcut to add !inlineSuggestionVisible to the when conditions. This disables the Markdown extension's Tab behavior when Copilot is showing a suggestion, allowing the editor.action.inlineSuggest.commit binding on Tab to take over.

Whether or not this option gets added, for anyone else needing to enable Copilot or other inline-suggestion tools to work when using this extension, you can update your keybindings.json (Ctrl+Shift+p, then find Preferences: Open Keyboard Shortcuts (JSON)) by adding the following:

[
  {
    "key": "tab",
    "command": "markdown.extension.onTabKey",
    "when": "editorTextFocus && !inlineSuggestionVisible && !editorReadonly && !editorTabMovesFocus && !hasOtherSuggestions && !hasSnippetCompletions && !inSnippetMode && !suggestWidgetVisible && editorLangId == 'markdown'"
  },
  {
    "key": "tab",
    "command": "-markdown.extension.onTabKey",
    "when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus && !hasOtherSuggestions && !hasSnippetCompletions && !inSnippetMode && !suggestWidgetVisible && editorLangId == 'markdown'"
  }
]

The first entry adds the !inlineSuggestionVisible condition, and the second entry essentially blocks the shortcut that comes with the Markdown All In One extension.

@adam-coster adam-coster changed the title Improve GitHub Copilot compatibility with config option to allow inline suggestions Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with <kbr>Tab</kbr> Sep 14, 2021
@adam-coster adam-coster changed the title Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with <kbr>Tab</kbr> Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Sep 14, 2021
@adam-coster adam-coster changed the title Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Sep 14, 2021
@adam-coster adam-coster changed the title Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Sep 14, 2021
@adam-coster
Copy link
Author

Additional reference from the VSCode repo: microsoft/vscode#131953

@Lemmingh Lemmingh added Area: Input Related to editor input processing (key presses, key bindings). Needs More Info labels Sep 15, 2021
@Lemmingh

This comment has been minimized.

@adam-coster

This comment has been minimized.

@yzhang-gh
Copy link
Owner

yzhang-gh commented Sep 15, 2021

We can add the !inlineSuggestionVisible but I think we also need to ask VS Code to document it (what is its meaning and when is it used).

(should be available in the dev build now.)

@MitchTalmadge
Copy link

I've confirmed this works to solve the problem I was experiencing in microsoft/vscode#131953. Thank you for this solution.

@Lemmingh Lemmingh changed the title Improve GitHub Copilot compatibility with config option to allow accepting inline suggestions with Tab Respect Inline Suggestion to improve compatibility with GitHub Copilot Sep 25, 2021
@Lemmingh Lemmingh added Issue: Bug Res: Duplicate This issue or pull request already exists. and removed Needs More Info labels Sep 25, 2021
stoe added a commit to stoe/.dotfiles that referenced this issue Oct 24, 2021
@Lemmingh Lemmingh added Res: Fixed Fix is checked in, but it might be a few weeks until a release. Upstream Pertaining to an upstream component, or blocked by an upstream issue. and removed Res: Duplicate This issue or pull request already exists. labels Oct 29, 2021
@Lemmingh Lemmingh added this to the v3.5.0 milestone Oct 29, 2021
@Lemmingh
Copy link
Collaborator

GitHub Copilot takes advantage of several proposed or private features of VS Code, such as Inline Suggestion (microsoft/vscode#124024).

In case of intense changes like microsoft/vscode#125498, we should keep this issue open until the finalization of these APIs, and also monitor the following:

@JoyShaheb
Copy link

The Solution provided by @adam-coster worked for me, Thank you !

@Djcarrillo6
Copy link

Solution referenced above works for me as well! Thank you!!

@fonnesbeck
Copy link

This does not work for me on Windows (nor does uninstalling Markdown All In One).

@Franky1
Copy link

Franky1 commented Dec 20, 2021

I tried the solution, but could not edit the keybindings.json file. VSCode says it is write protected. I found no option to unlock.

  • OS Windows 10
  • VSCode Version 1.63.2

EDIT: I was wrong, i was in the default keyboard settings...

@yzhang-gh
Copy link
Owner

Just a note, you can install the dev build to get the fix.

@sasukeh
Copy link

sasukeh commented Jan 31, 2022

@adam-coster 's workaround is works for me for now! Thanks @adam-coster .

@Jont828
Copy link

Jont828 commented Feb 8, 2022

Thanks @adam-coster. It worked for me!

NickCrews added a commit to NickCrews/vscode-restructuredtext that referenced this issue Feb 9, 2022
I was using another extension (GitHub CoPilot) and I was finding that the tab-to-complete wasn't working with it. Similar to the diagnosis at yzhang-gh/vscode-markdown#1011, the keybinding for this extension was taking precedence, eating the tab before CoPilot could get it. Therefore, this PR makes the keybinding more strict in when it accepts a "tab" event.

Tested on my machine, it fixes the problem as described in that issue. Not sure if this will affect other aspects of this extension?
@dlintin
Copy link

dlintin commented Feb 11, 2022

This solution is working great for me at the time! for those who on mac can use (⇧⌘P) to select the Preferences: Open Keyboard Shortcuts (JSON)

@laakal
Copy link

laakal commented Feb 14, 2022

It's also conflicts with the docs-markdown extension. It works after deleting the docs-markdown extension.

lencioni added a commit to lencioni/dotfiles that referenced this issue Mar 15, 2022
I noticed that tab-completion for GitHub Copilot was not working for me
in markdown files. I found a workaround that someone posted and it seems
to do the trick for me.

yzhang-gh/vscode-markdown#1011

In my reading of the linked issue it seems that a fix may eventually
land in the extension in which case I should be able to remove this
keybinding.
@andig
Copy link

andig commented Mar 23, 2022

Checking in here. It would be nice to get copilot compatibility out of the box.

@anbarasanv
Copy link

Thank you very much works fine for me on my Mac.

yzhang-gh added a commit that referenced this issue Apr 17, 2022
@yzhang-gh
Copy link
Owner

has been fixed in v3.4.2

@MitchTalmadge
Copy link

Thank you so much

@Lemmingh
Copy link
Collaborator

Lemmingh commented Jun 8, 2022

The Inline Completions API is finalized in VS Code May 2022 (version 1.68) released this weekend.

No noticeable changes.


Sigh: It has been one year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Input Related to editor input processing (key presses, key bindings). Issue: Bug Res: Fixed Fix is checked in, but it might be a few weeks until a release. Upstream Pertaining to an upstream component, or blocked by an upstream issue.
Projects
None yet
Development

No branches or pull requests