Skip to content

Commit e84d7ea

Browse files
committed
Fix tuple regex
1 parent 1857bbb commit e84d7ea

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

autoload/sj/python.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function! sj#python#SplitTuple()
8888
endfunction
8989

9090
function! sj#python#JoinTuple()
91-
return s:JoinList('([^)]*\s*$', '(', ')')
91+
return s:JoinList('([^()]*\s*$', '(', ')')
9292
endfunction
9393

9494
function! sj#python#SplitImport()

spec/plugin/python_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
before :each do
77
vim.set(:expandtab)
88
vim.set(:shiftwidth, 4)
9+
10+
vim.command 'unlet! b:splitjoin_python_import_style'
11+
vim.command 'unlet! b:splitjoin_python_brackets_on_separate_lines'
912
end
1013

1114
specify "dictionaries" do
@@ -282,6 +285,30 @@ def example():
282285
EOF
283286
end
284287

288+
specify "tuple within tuple" do
289+
set_file_contents <<~EOF
290+
out = Foo(Bar(baz, bla))
291+
EOF
292+
293+
vim.command 'let b:splitjoin_python_brackets_on_separate_lines = 1'
294+
vim.search('baz')
295+
split
296+
297+
assert_file_contents <<~EOF
298+
out = Foo(Bar(
299+
baz,
300+
bla
301+
))
302+
EOF
303+
304+
vim.search('Bar\zs(')
305+
join
306+
307+
assert_file_contents <<~EOF
308+
out = Foo(Bar(baz, bla))
309+
EOF
310+
end
311+
285312
specify "list comprehensions" do
286313
pending "Old version on CI" if ENV['CI']
287314

0 commit comments

Comments
 (0)