Skip to content

Commit cace6c9

Browse files
committed
Special case for dicts assigned to function args
1 parent 369fc01 commit cace6c9

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

autoload/sj/python.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function! sj#python#SplitTuple()
102102
endfunction
103103

104104
function! sj#python#SplitArgs()
105-
if search('\%#[[:keyword:].]\+(', 'e', line('.'))
105+
if search('\%#[[:keyword:].=]\+(', 'e', line('.'))
106106
return sj#python#SplitTuple()
107107
endif
108108
endfunction
@@ -112,7 +112,7 @@ function! sj#python#JoinTuple()
112112
endfunction
113113

114114
function! sj#python#JoinArgs()
115-
if search('\%#[[:keyword:].]\+(', 'e', line('.'))
115+
if search('\%#[[:keyword:].=]\+(', 'e', line('.'))
116116
return sj#python#JoinTuple()
117117
endif
118118
endfunction

spec/plugin/python_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@
4747
assert_file_contents "spam = {spam: [1, 2, 3], 'spam, spam': 'eggs'}"
4848
end
4949

50+
specify "a dictionary passed to a named variable" do
51+
set_file_contents "function_call(spam=dict(eggs=[1, 2], ham=[3, 4])))"
52+
53+
vim.search 'spam='
54+
split
55+
56+
assert_file_contents <<~EOF
57+
function_call(spam=dict(eggs=[1, 2],
58+
ham=[3, 4])))
59+
EOF
60+
61+
join
62+
63+
assert_file_contents "function_call(spam=dict(eggs=[1, 2], ham=[3, 4])))"
64+
end
65+
5066
specify "lists" do
5167
set_file_contents 'spam = [1, [2, 3], 4]'
5268

0 commit comments

Comments
 (0)