Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d36f06

Browse files
committed
Fix Autoimport on unsaved file
1 parentb65f669 commit0d36f06

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

‎autoload/pymode.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ fun! pymode#save() "{{{
8686
try
8787
noautocmdwrite
8888
catch/E212/
89-
callpymode#error("File modified and I can't save it.Cancel code checking.")
89+
callpymode#error("File modified and I can't save it.Please save it manually.")
9090
return0
9191
endtry
9292
endif
93-
return1
93+
returnexpand('%')!=''
9494
endfunction"}}}
9595

9696
fun!pymode#reload_buf_by_nr(nr)"{{{

‎autoload/pymode/rope.vim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ fun! pymode#rope#module_to_package() "{{{
161161
endfunction"}}}
162162

163163
fun!pymode#rope#autoimport(word)"{{{
164-
if!pymode#save()
165-
return0
166-
endif
167164
PymodePython rope.autoimport()
168165
endfunction"}}}
169166

‎pymode/rope.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,13 @@ def complete_check():
909909

910910

911911
def_insert_import(name,module,ctx):
912+
ifnotctx.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+
returnTrue
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)

‎t/plugin.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ describe 'pymode-plugin'
2727
Expectgetline('$')=='test success'
2828
end
2929

30+
it'pymode save'
31+
Expectexpand('%')==''
32+
Expectpymode#save()==0
33+
end
34+
3035
end
3136

3237

‎t/rope.vim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
letg:pymode_rope_completion_bind='X'
22
letg:pymode_rope_autoimport=0
3-
43
sourceplugin/pymode.vim
54

65
describe'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
Expectisdirectory(project_path)==0
2019
callpymode#rope#complete(0)
2120
Expectisdirectory(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
Expectgetline('.')=='import'
2926
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp