Skip to content

Commit bfd70f7

Browse files
committed
fixed auto insert for rope complete
For details, see `:h completeopt` in vim. vim has many flags of option &completeopt, the flags like menu, menuone, noinsert, noselect and so on control the autocomplete behaviour. e.g. if the set completeopt=menu, and there's only one possible completions, the vim will not popup a menu and just insert the completions, this like auto insert __init__ describe above, user there's no chance to confirm the completions they want or not. but if set completeopt=menuone,noinsert, vim will popup menu also when there is only one match. for case above, vim will popup a menu with one completion item __init__ and let user choose insert it or escape, if add noselect with &completeopt, vim will even not selected the first completion item.
1 parent ac97c66 commit bfd70f7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

autoload/pymode/rope.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ endfunction
1515

1616
fun! pymode#rope#complete(dot)
1717
if pumvisible()
18-
return "\<C-n>"
18+
if stridx('noselect', &completeopt) != -1
19+
return "\<C-n>"
20+
else
21+
return ""
22+
endif
1923
endif
2024
if a:dot
2125
PymodePython rope.complete(True)
2226
else
2327
PymodePython rope.complete()
2428
endif
25-
return pumvisible() ? "\<C-p>\<Down>" : ""
29+
return pumvisible() && stridx('noselect', &completeopt) != -1 ? "\<C-p>\<Down>" : ""
2630
endfunction
2731

2832
fun! pymode#rope#complete_on_dot() "{{{

pymode/rope.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def complete(dot=False):
9494
line = env.lines[row - 1]
9595
cline = line[:col] + p_prefix + line[col:]
9696
if cline != line:
97-
env.curbuf[row - 1] = env.prepare_value(cline, dumps=False)
97+
if 'noinsert' not in env.var('&completeopt'):
98+
env.curbuf[row - 1] = env.prepare_value(cline, dumps=False)
9899
env.current.window.cursor = (row, col + len(p_prefix))
99100
env.run('complete', col - len(prefix) + len(p_prefix) + 1, proposals)
100101
return True

0 commit comments

Comments
 (0)