Skip to content

Commit

Permalink
Resolve old TODO, fix attempt to split 1-length item
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRadev committed Nov 18, 2023
1 parent 4daf089 commit 922a89c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions autoload/sj/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,18 @@ function! sj#python#JoinAssignment()
endfunction

function! s:SplitList(regex, opening_char, closing_char)
if sj#SearchUnderCursor(a:regex) <= 0
let [from, to] = sj#LocateBracesAroundCursor(a:opening_char, a:closing_char, ['pythonString'])
if from < 0 && to < 0
return 0
endif

call sj#PushCursor()

" TODO (2012-10-24) connect sj#SearchUnderCursor and sj#LocateBracesOnLine
normal! l
let start = col('.')
normal! h%h
let end = col('.')

let items = sj#ParseJsonObjectBody(start, end)
let items = sj#ParseJsonObjectBody(from + 1, to - 1)
if len(items) <= 1
call sj#PopCursor()
return 0
endif

if sj#settings#Read('python_brackets_on_separate_lines')
if sj#settings#Read('trailing_comma')
Expand All @@ -256,7 +255,6 @@ function! s:SplitList(regex, opening_char, closing_char)
endif

call sj#PopCursor()

call sj#ReplaceMotion('va'.a:opening_char, body)
return 1
endfunction
Expand Down

0 comments on commit 922a89c

Please sign in to comment.