File tree Expand file tree Collapse file tree 5 files changed +15
-9
lines changed
Expand file tree Collapse file tree 5 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -86,11 +86,11 @@ fun! pymode#save() "{{{
8686 try
8787 noautocmd write
8888 catch /E212/
89- call pymode#error (" File modified and I can't save it. Cancel code checking ." )
89+ call pymode#error (" File modified and I can't save it. Please save it manually ." )
9090 return 0
9191 endtry
9292 endif
93- return 1
93+ return expand ( ' % ' ) != ' '
9494endfunction " }}}
9595
9696fun ! pymode#reload_buf_by_nr (nr) " {{{
Original file line number Diff line number Diff line change @@ -161,9 +161,6 @@ fun! pymode#rope#module_to_package() "{{{
161161endfunction " }}}
162162
163163fun ! pymode#rope#autoimport (word) " {{{
164- if ! pymode#save ()
165- return 0
166- endif
167164 PymodePython rope.autoimport ()
168165endfunction " }}}
169166
Original file line number Diff line number Diff line change @@ -909,6 +909,13 @@ def complete_check():
909909
910910
911911def _insert_import (name , module , ctx ):
912+ if not ctx .resource :
913+ source , _ = get_assist_params ()
914+ lineno = ctx .importer .find_insertion_line (source )
915+ line = 'from %s import %s' % (module , name )
916+ vim .current .buffer [lineno - 1 :lineno - 1 ] = [line ]
917+ return True
918+
912919 pyobject = ctx .project .pycore .resource_to_pyobject (ctx .resource )
913920 import_tools = importutils .ImportTools (ctx .project .pycore )
914921 module_imports = import_tools .module_imports (pyobject )
Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ describe 'pymode-plugin'
2727 Expect getline (' $' ) == ' test success'
2828 end
2929
30+ it ' pymode save'
31+ Expect expand (' %' ) == ' '
32+ Expect pymode#save () == 0
33+ end
34+
3035end
3136
3237
Original file line number Diff line number Diff line change 11let g: pymode_rope_completion_bind = ' X'
22let g: pymode_rope_autoimport = 0
3-
43source plugin /pymode.vim
54
65describe ' pymode-plugin'
@@ -15,15 +14,13 @@ describe 'pymode-plugin'
1514 end
1615
1716 it ' pymode rope auto open project in current working directory'
18- let project_path = getcwd () . ' / .ropeproject'
17+ let project_path = ' .ropeproject'
1918 Expect isdirectory (project_path) == 0
2019 call pymode#rope#complete (0 )
2120 Expect isdirectory (project_path) == 1
2221 end
2322
2423 it ' pymode rope completion'
25- source after/ftplugin/ python .vim
26- Expect &ft == ' python'
2724 normal oimporX
2825 Expect getline (' .' ) == ' import'
2926 end
You can’t perform that action at this time.
0 commit comments