golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.21k stars 17.7k forks source link

x/tools/gopls: feature: support SnippetTextEdit in codeactions #70432

Open xzbdmw opened 3 days ago

xzbdmw commented 3 days ago

gopls version

.

go env

.

What did you do?

Jdtls's preview version has this feature, and lsp has snippetTextEdit merged

What did you see happen?

https://github.com/user-attachments/assets/6fcb6b07-150b-4401-bd07-fee7a93cb129

What did you expect to see?

With snippets, for extract function/method/variable, we can change function/variable name in two places at the same time; for fill struct, all the right side of property assignment can be a snippet node; and for generate missing function/method, we can select the panic("unimplemented") so user can replace it right away.

Editor and settings

No response

Logs

No response

adonovan commented 2 days ago

I think the intent of the video is to illustrate that applying the code action causes the selection and cursor to change, not just a mere text edit. The mechanism is similar to a snippet completion, which returns a snippet of text with placeholder fields in it.

gabyhelp commented 2 days ago

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)