Skip to content

Commit 1e26220

Browse files
committed
Avoid mixed types even without rhs values
1 parent ac26ff6 commit 1e26220

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

autoload/sj/go.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function! sj#go#JoinVars() abort
131131
return 0
132132
endif
133133

134-
if len(values) > 0 && len(uniq(types)) > 1
134+
if len(uniq(types)) > 1
135135
" We have assignment to values, but we also have different types, so it
136136
" can't be on one line
137137
return 0

spec/plugin/go_spec.rb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,15 @@ def assert_split_join(initial, split_expected, join_expected)
324324
specify "comma-separated with type, without values" do
325325
set_file_contents <<~EOF
326326
const (
327-
const4 string,
328-
const5 string,
329-
const6 int[]
330-
const7 int[]
327+
const4 string
328+
const5 string
331329
)
332330
EOF
333331

334332
join
335333

336334
assert_file_contents <<~EOF
337-
const const4, const5 string, const6, const7 int[]
335+
const const4, const5 string
338336
EOF
339337

340338
split
@@ -343,8 +341,24 @@ def assert_split_join(initial, split_expected, join_expected)
343341
const (
344342
const4 string
345343
const5 string
346-
const6 int[]
347-
const7 int[]
344+
)
345+
EOF
346+
end
347+
348+
specify "different types don't get joined" do
349+
set_file_contents <<~EOF
350+
const (
351+
const4 string
352+
const5 int
353+
)
354+
EOF
355+
356+
join
357+
358+
# Triggers the built-in gJ
359+
assert_file_contents <<~EOF
360+
const ( const4 string
361+
const5 int
348362
)
349363
EOF
350364
end

0 commit comments

Comments
 (0)