test(struct_tags): add support for multiple structs
This commit is contained in:
parent
59169df030
commit
59a0e961c4
4 changed files with 49 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ function ts.get_struct_node_at_pos(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local res = {}
|
local res = {}
|
||||||
local r = get_parrent_node("type_declaration", node)
|
local r = get_parrent_node("type_spec", node)
|
||||||
if not r then
|
if not r then
|
||||||
error "No struct found under cursor"
|
error "No struct found under cursor"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
18
spec/fixtures/tags/many_input.go
vendored
Normal file
18
spec/fixtures/tags/many_input.go
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type (
|
||||||
|
TestOne struct {
|
||||||
|
Asdf string
|
||||||
|
ID int
|
||||||
|
}
|
||||||
|
|
||||||
|
TestTwo struct {
|
||||||
|
Fesa int
|
||||||
|
A bool
|
||||||
|
}
|
||||||
|
|
||||||
|
TestThree struct {
|
||||||
|
Asufj int
|
||||||
|
Fs string
|
||||||
|
}
|
||||||
|
)
|
||||||
18
spec/fixtures/tags/many_output.go
vendored
Normal file
18
spec/fixtures/tags/many_output.go
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type (
|
||||||
|
TestOne struct {
|
||||||
|
Asdf string
|
||||||
|
ID int
|
||||||
|
}
|
||||||
|
|
||||||
|
TestTwo struct {
|
||||||
|
Fesa int `testing:"fesa"`
|
||||||
|
A bool `testing:"a"`
|
||||||
|
}
|
||||||
|
|
||||||
|
TestThree struct {
|
||||||
|
Asufj int
|
||||||
|
Fs string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -34,4 +34,16 @@ T["struct_tags"]["works remove"] = function()
|
||||||
t.eq(t.readfile(tmp), fixtures.output)
|
t.eq(t.readfile(tmp), fixtures.output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
T["struct_tags"]["works many structs"] = function()
|
||||||
|
local tmp = t.tmpfile()
|
||||||
|
local fixtures = t.get_fixtures "tags/many"
|
||||||
|
t.writefile(tmp, fixtures.input)
|
||||||
|
|
||||||
|
child.cmd("silent edit " .. tmp)
|
||||||
|
child.fn.setpos(".", { child.fn.bufnr "%", 10, 3, 0 })
|
||||||
|
child.cmd "GoTagAdd testing"
|
||||||
|
|
||||||
|
t.eq(t.readfile(tmp), fixtures.output)
|
||||||
|
end
|
||||||
|
|
||||||
return T
|
return T
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue