mirror of
https://github.com/golang/go
synced 2024-11-19 00:04:40 -07:00
7d589f28aa
After some discussion about how to handle insert and filter text (https://github.com/microsoft/vscode-languageserver-node/issues/488), it seems that it is better practice to overwrite the prefix in completion items, rather than trimming the prefix from the insert text. Change-Id: I7c794b4b1d4518af31e7318a283aa3681a0cf66a Reviewed-on: https://go-review.googlesource.com/c/tools/+/176958 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
31 lines
953 B
Go
31 lines
953 B
Go
package snippets
|
|
|
|
func foo(i int, b bool) {} //@item(snipFoo, "foo(i int, b bool)", "", "func")
|
|
func bar(fn func()) func() {} //@item(snipBar, "bar(fn func())", "", "func")
|
|
|
|
type Foo struct {
|
|
Bar int //@item(snipFieldBar, "Bar", "int", "field")
|
|
}
|
|
|
|
func (Foo) Baz() func() {} //@item(snipMethodBaz, "Baz()", "func()", "field")
|
|
|
|
func _() {
|
|
f //@snippet(" //", snipFoo, "foo(${1})", "foo(${1:i int}, ${2:b bool})")
|
|
|
|
bar //@snippet(" //", snipBar, "bar(${1})", "bar(${1:fn func()})")
|
|
|
|
bar(nil) //@snippet("(", snipBar, "bar", "bar")
|
|
bar(ba) //@snippet(")", snipBar, "bar(${1})", "bar(${1:fn func()})")
|
|
var f Foo
|
|
bar(f.Ba) //@snippet(")", snipMethodBaz, "Baz()", "Baz()")
|
|
|
|
Foo{
|
|
B //@snippet(" //", snipFieldBar, "Bar: ${1},", "Bar: ${1:int},")
|
|
}
|
|
|
|
Foo{B} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
|
Foo{} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
|
|
|
Foo{Foo{}.B} //@snippet("} ", snipFieldBar, "Bar", "Bar")
|
|
}
|