Skip to content

Commit 7a449a5

Browse files
authored
Merge pull request python-mode#984 from zcodes/fix-anonying-auto-insert
fixed auto insert for rope complete
2 parents 166268a + 344502c commit 7a449a5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
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() "{{{

doc/pymode.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pymode.txt* For Vim Version 8.0 Last change: 2017 November 20
1+
*pymode.txt* For Vim Version 8.0 Last change: 2019 March 08
22

33
____ _ _ ____ _ _ _____ _ _ __ __ _____ ____ ____ ~
44
( _ \( \/ )(_ _)( )_( )( _ )( \( )___( \/ )( _ )( _ \( ___) ~
@@ -483,6 +483,12 @@ your code. <C-X><C-O> and <C-P>/<C-N> works too.
483483

484484
Autocompletion is also called by typing a period in |Insert| mode by default.
485485

486+
If there's only one complete item, vim may be inserting it automatically
487+
instead of using a popup menu. If the complete item which inserted is not
488+
your wanted, you can roll it back use '<c-w>' in |Insert| mode or setup
489+
'completeopt' with `menuone` and `noinsert` in your vimrc. .e.g.
490+
>
491+
set completeopt=menuone,noinsert
486492
487493
Turn on code completion support in the plugin *'g:pymode_rope_completion'*
488494
>

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)