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

Accepted completions should be applied to all active cursors (particular when using snippets) #268

Closed
axefrog opened this issue Jun 20, 2023 · 2 comments
Assignees

Comments

@axefrog
Copy link

axefrog commented Jun 20, 2023

If I have multiple cursors active, it means I want to perform the same operations (typing, selecting, etc.) at each cursor location. I'm often using snippets that utilise multiple cursors. Copilot would be very helpful in these cases, except that it only applies edits to the first cursor. This is of particular issue when utilising multi-cursor snippets, as it prevents the intended behaviour of the snippet from taking effect when Copilot is trying to be helpful. Here's a TypeScript snippet I use all the time as a good example:

{
    "prefix": "cp0",
    "body": [
      "constructor (${1:a}) {",
      "\tsuper($9);",
      "\t${1/([^, :]+)(?:: *(?:[A-Za-z0-9_. |&[\\]]+(?:<[^>]+>)?)*)?(, )?/this.#$1 = $1;${2:+\n\t}/g}",
      "}$0",
      "${1/([^, :]+)(: *(?:[A-Za-z0-9_. |&[\\]]+(?:<[^>]+>)?)*)?(, )?/readonly #$1$2${3:+;\n}/g};",
    ]
}

It helps write an initial constructor signature. You just type the parameter list as you would normally, and it generates all the private class fields and the initial assignment statements in the constructor. A demonstration is below. You can see the usefulness of the snippet, and you can see Copilot trying to be helpful. Copilot is offering me correct suggestions that I'd like to accept. Unfortunately, if I were to do so it would only affect the first cursor, which would mess up the snippet's regex replacement behaviour when finalising the snippet.

Code_-_Insiders_2023-06-21_05-49-58

@github-actions github-actions bot added the triage-needed Issues needing to be assigned to the prospective feature owner label Jun 20, 2023
@jrieken jrieken assigned hediet and unassigned jrieken Jun 21, 2023
@lramos15 lramos15 removed the triage-needed Issues needing to be assigned to the prospective feature owner label Jun 26, 2023
@JetUni
Copy link

JetUni commented Oct 31, 2023

This is actually a problem whether or not you're using snippets. I just got an enterprise license from my company and started using Copilot again and forgot how much I hated this bug. I am in the middle of a massive refactor of code, and multi-cursor is the easiest way to change all of the lines at the same time and save myself some time, but Copilot overrides the default VS Code intellisense, so when it suggests something, I can't use that suggestion for every line that I have my cursor on. It only applies to the first line that I selected. On the other hand, the VS Code intellisense knows that when I have multi-cursor enabled, it should apply the accepted suggestion to ALL lines, not just the first (even though it only shows the suggestion on the first line still)

@hediet
Copy link
Member

hediet commented Nov 6, 2023

Duplicate of microsoft/vscode#146041

Please upvote to indicate your interest in this feature!

@hediet hediet marked this as a duplicate of microsoft/vscode#146041 Nov 6, 2023
@hediet hediet closed this as completed Nov 6, 2023
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants