Skip to content

Commit 5d1c910

Browse files
committed
Minor refactoring
1 parent b6a1a56 commit 5d1c910

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

autoload/sj/python.vim

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,23 @@ endfunction
5353
function! sj#python#JoinDict()
5454
let line = getline('.')
5555

56-
if line =~ '{\s*$'
57-
call search('{', 'c', line('.'))
58-
let body = sj#GetMotion('Vi{')
56+
if line !~ '{\s*$'
57+
return 0
58+
endif
5959

60-
let lines = sj#TrimList(split(body, "\n"))
61-
if sj#settings#Read('normalize_whitespace')
62-
let lines = map(lines, 'substitute(v:val, ":\\s\\+", ": ", "")')
63-
endif
60+
call search('{', 'c', line('.'))
61+
let body = sj#GetMotion('Vi{')
6462

65-
let body = join(lines, ' ')
66-
if sj#settings#Read('trailing_comma')
67-
let body = substitute(body, ',\?$', '', '')
68-
endif
63+
let lines = sj#TrimList(split(body, "\n"))
64+
if sj#settings#Read('normalize_whitespace')
65+
let lines = map(lines, 'substitute(v:val, ":\\s\\+", ": ", "")')
66+
endif
6967

70-
call sj#ReplaceMotion('Va{', '{'.body.'}')
68+
let body = join(lines, ' ')
69+
let body = substitute(body, ',\?$', '', '')
7170

72-
return 1
73-
else
74-
return 0
75-
endif
71+
call sj#ReplaceMotion('Va{', '{'.body.'}')
72+
return 1
7673
endfunction
7774

7875
function! sj#python#SplitArray()

0 commit comments

Comments
 (0)