@@ -56,9 +56,7 @@ func TestRegister(t *testing.T) {
56
56
},
57
57
func (n * nvim.Nvim , args []string ) error {
58
58
chunks := []nvim.TextChunk {
59
- {
60
- Text : `Hello` ,
61
- },
59
+ {Text : `Hello` },
62
60
}
63
61
for _ , arg := range args {
64
62
chunks = append (chunks , nvim.TextChunk {Text : arg })
@@ -68,6 +66,36 @@ func TestRegister(t *testing.T) {
68
66
},
69
67
)
70
68
69
+ // CommandRangeDotHandler
70
+ p .HandleCommand (
71
+ & plugin.CommandOptions {
72
+ Name : "HelloRangeDot" ,
73
+ Range : "." ,
74
+ },
75
+ func (n * nvim.Nvim ) error {
76
+ chunks := []nvim.TextChunk {
77
+ {Text : `Hello` },
78
+ }
79
+
80
+ return n .Echo (chunks , true , make (map [string ]interface {}))
81
+ },
82
+ )
83
+
84
+ // CommandCountHandler
85
+ p .HandleCommand (
86
+ & plugin.CommandOptions {
87
+ Name : "HelloCount" ,
88
+ Count : "0" ,
89
+ },
90
+ func (n * nvim.Nvim ) error {
91
+ chunks := []nvim.TextChunk {
92
+ {Text : `Hello` },
93
+ }
94
+
95
+ return n .Echo (chunks , true , make (map [string ]interface {}))
96
+ },
97
+ )
98
+
71
99
// CommandEvalHandler
72
100
p .HandleCommand (
73
101
& plugin.CommandOptions {
@@ -86,7 +114,7 @@ func TestRegister(t *testing.T) {
86
114
)
87
115
88
116
if err := p .RegisterForTests (); err != nil {
89
- t .Fatalf ("register for test: %v" , err )
117
+ t .Fatalf ("register handlers for test: %v" , err )
90
118
}
91
119
92
120
t .Run ("SimpleHandler" , func (t * testing.T ) {
@@ -138,6 +166,30 @@ func TestRegister(t *testing.T) {
138
166
}
139
167
})
140
168
169
+ t .Run ("CommandRangeDotHandler" , func (t * testing.T ) {
170
+ result , err := p .Nvim .Exec (`HelloRangeDot` , true )
171
+ if err != nil {
172
+ t .Fatalf ("exec 'Hello' command: %v" , err )
173
+ }
174
+
175
+ expected := `Hello`
176
+ if result != expected {
177
+ t .Fatalf ("Hello returned %q, want %q" , result , expected )
178
+ }
179
+ })
180
+
181
+ t .Run ("CommandCountHandler" , func (t * testing.T ) {
182
+ result , err := p .Nvim .Exec (`HelloCount` , true )
183
+ if err != nil {
184
+ t .Fatalf ("exec 'Hello' command: %v" , err )
185
+ }
186
+
187
+ expected := `Hello`
188
+ if result != expected {
189
+ t .Fatalf ("Hello returned %q, want %q" , result , expected )
190
+ }
191
+ })
192
+
141
193
t .Run ("CommandEvalHandler" , func (t * testing.T ) {
142
194
result , err := p .Nvim .Exec (`HelloEval` , true )
143
195
if err != nil {
0 commit comments