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()
92
92
endfunction
93
93
94
94
function ! sj#python#SplitImport ()
95
- let import_pattern = ' ^from \%(.*\) import \zs.*$'
95
+ let import_pattern = ' ^\s* from \%(.*\) import \zs.*$'
96
96
97
97
normal ! 0
98
98
if search (import_pattern, ' Wc' , line (' .' )) <= 0
@@ -141,7 +141,7 @@ function! sj#python#SplitImport()
141
141
endfunction
142
142
143
143
function ! sj#python#JoinImportWithNewlineEscape ()
144
- let import_pattern = ' ^from \%(.*\) import .*\\\s*$'
144
+ let import_pattern = ' ^\s* from \%(.*\) import .*\\\s*$'
145
145
if getline (' .' ) !~ import_pattern
146
146
return 0
147
147
endif
@@ -160,7 +160,7 @@ function! sj#python#JoinImportWithNewlineEscape()
160
160
endfunction
161
161
162
162
function ! sj#python#JoinImportWithRoundBrackets ()
163
- let import_pattern = ' ^from \%(.*\) import \zs('
163
+ let import_pattern = ' ^\s* from \%(.*\) import \zs('
164
164
if search (import_pattern, ' Wc' ) <= 0
165
165
return 0
166
166
endif
Original file line number Diff line number Diff line change 62
62
end
63
63
64
64
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
66
69
70
+ vim . search ( 'from foo' )
67
71
split
68
72
69
73
assert_file_contents <<~EOF
70
- from foo import bar,\\
71
- baz
74
+ def surrounding_function():
75
+ from foo import bar,\\
76
+ baz
72
77
EOF
73
78
74
79
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
76
84
77
85
vim . command 'let b:splitjoin_python_import_style = "round_brackets"'
78
86
split
79
87
80
88
assert_file_contents <<~EOF
81
- from foo import (bar,
82
- baz)
89
+ def surrounding_function():
90
+ from foo import (bar,
91
+ baz)
83
92
EOF
84
93
85
94
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
87
99
88
100
vim . command 'let b:splitjoin_python_brackets_on_separate_lines = 1'
89
101
split
90
102
91
103
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
+ )
96
109
EOF
97
110
98
111
join
You can’t perform that action at this time.
0 commit comments