File tree Expand file tree Collapse file tree 2 files changed +27
-14
lines changed
Expand file tree Collapse file tree 2 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ function! sj#python#JoinTuple()
9292endfunction
9393
9494function ! sj#python#SplitImport ()
95- let import_pattern = ' ^from \%(.*\) import \zs.*$'
95+ let import_pattern = ' ^\s* from \%(.*\) import \zs.*$'
9696
9797 normal ! 0
9898 if search (import_pattern, ' Wc' , line (' .' )) <= 0
@@ -141,7 +141,7 @@ function! sj#python#SplitImport()
141141endfunction
142142
143143function ! sj#python#JoinImportWithNewlineEscape ()
144- let import_pattern = ' ^from \%(.*\) import .*\\\s*$'
144+ let import_pattern = ' ^\s* from \%(.*\) import .*\\\s*$'
145145 if getline (' .' ) !~ import_pattern
146146 return 0
147147 endif
@@ -160,7 +160,7 @@ function! sj#python#JoinImportWithNewlineEscape()
160160endfunction
161161
162162function ! sj#python#JoinImportWithRoundBrackets ()
163- let import_pattern = ' ^from \%(.*\) import \zs('
163+ let import_pattern = ' ^\s* from \%(.*\) import \zs('
164164 if search (import_pattern, ' Wc' ) <= 0
165165 return 0
166166 endif
Original file line number Diff line number Diff line change 6262 end
6363
6464 specify "imports" do
65- set_file_contents 'from foo import bar, baz'
65+ set_file_contents <<~EOF
66+ def surrounding_function():
67+ from foo import bar, baz
68+ EOF
6669
70+ vim . search ( 'from foo' )
6771 split
6872
6973 assert_file_contents <<~EOF
70- from foo import bar,\\
71- baz
74+ def surrounding_function():
75+ from foo import bar,\\
76+ baz
7277 EOF
7378
7479 join
75- assert_file_contents 'from foo import bar, baz'
80+ assert_file_contents <<~EOF
81+ def surrounding_function():
82+ from foo import bar, baz
83+ EOF
7684
7785 vim . command 'let b:splitjoin_python_import_style = "round_brackets"'
7886 split
7987
8088 assert_file_contents <<~EOF
81- from foo import (bar,
82- baz)
89+ def surrounding_function():
90+ from foo import (bar,
91+ baz)
8392 EOF
8493
8594 join
86- assert_file_contents 'from foo import bar, baz'
95+ assert_file_contents <<~EOF
96+ def surrounding_function():
97+ from foo import bar, baz
98+ EOF
8799
88100 vim . command 'let b:splitjoin_python_brackets_on_separate_lines = 1'
89101 split
90102
91103 assert_file_contents <<~EOF
92- from foo import (
93- bar,
94- baz
95- )
104+ def surrounding_function():
105+ from foo import (
106+ bar,
107+ baz
108+ )
96109 EOF
97110
98111 join
You can’t perform that action at this time.
0 commit comments