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

Show "Surround with snippet" in quick fix menu #150678

Closed
bpasero opened this issue May 30, 2022 · 8 comments · Fixed by #152718
Closed

Show "Surround with snippet" in quick fix menu #150678

bpasero opened this issue May 30, 2022 · 8 comments · Fixed by #152718
Assignees
Labels
editor-code-actions Editor inplace actions (Ctrl + .) feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders snippets verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented May 30, 2022

I am not a big user of snippets, but I do really like them in the case where I want to surround some selected code with a snippet.

Could we not show an entry in the quick fix menu to surround the selection with a snippet?

image

@jrieken jrieken added feature-request Request for new features or functionality snippets editor-code-actions Editor inplace actions (Ctrl + .) labels Jun 7, 2022
@jrieken jrieken added this to the Backlog milestone Jun 7, 2022
@jrieken jrieken added the help wanted Issues identified as good community contribution opportunities label Jun 7, 2022
@babakks
Copy link
Contributor

babakks commented Jun 18, 2022

@jrieken I'm taking this if it's okay.

@babakks
Copy link
Contributor

babakks commented Jun 21, 2022

@jrieken I've submitted a PR. Could you please check it?

I also encountered a small problem at the snippet picker step, but just filed a separate issue (#152719) because I'm not sure if this PR is going to be merged.

@heartacker
Copy link
Contributor

heartacker commented Jun 24, 2022

@jrieken jrieken modified the milestones: Backlog, July 2022 Jun 27, 2022
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jul 15, 2022
@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 18, 2022
@jrieken jrieken added the verification-needed Verification of issue is requested label Jul 22, 2022
@jrieken
Copy link
Member

jrieken commented Jul 22, 2022

To verify

  • make sure editor.snippets.codeActions.enabled is true
  • open a TS file
  • have a non empty selection
  • trigger code actions (cmd+.) or wait for the light bulb
  • make sure there is "surround with XYZ" actions
  • select one which isn't the first
  • trigger the same code action again
  • make sure the surround actions are now sorted by recency
  • disable the setting mention above
  • make sure no surround-with actions are shown

@babakks
Copy link
Contributor

babakks commented Jul 22, 2022

@jrieken I tested this on the latest Insiders version. It seems working very well. Also tried using unlisted snippets, and they show up within the context menu the next time.

The only problem was that the editor.snippets.codeActions.enabled parameter was marked as unknown in the settings JSON (of course with no auto-completion) and neither enabling nor disabling it had any effect on the feature (i.e., the feature is always enabled).

My setup was:

Version: 1.70.0-insider
Commit: 13ba7bb446a638d37ebccb1a7d74e31c32bb9790
Date: 2022-07-22T05:17:40.120Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Linux x64 5.13.0-51-generic

@jrieken
Copy link
Member

jrieken commented Jul 22, 2022

the editor.snippets.codeActions.enabled parameter was marked as unknown in the settings

That change was only made today

@babakks
Copy link
Contributor

babakks commented Jul 22, 2022

@jrieken So it should work on the next Insiders build, right?

@babakks
Copy link
Contributor

babakks commented Jul 22, 2022

@jrieken One more thing, when I select any of the context menu "Surround With: X" items, except the first one, the next time they don't stand higher and keep their position. I tried to invoke them for several times, but they didn't move. Is this the desired behavior? I think it is, but just checking.

@bpasero bpasero added the verified Verification succeeded label Jul 26, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-code-actions Editor inplace actions (Ctrl + .) feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders snippets verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants