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

Commit5bece9d

Browse files
committed
make import completion not fall back to regular completion on no matches
1 parentcab1620 commit5bece9d

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

‎bpython/cli.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ def _complete(self, unused_tab=False):
561561
# Check for import completion
562562
e=False
563563
matches=importcompletion.complete(self.s,cw)
564+
ifmatchesisNone:
565+
self.scr.redrawwin()
566+
returnFalse
567+
564568
ifnotmatches:
565569
# Nope, no import, continue with normal completion
566570
try:

‎bpython/importcompletion.py‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,32 @@
3333
defcomplete(line,cw):
3434
"""Construct a full list of possibly completions for imports."""
3535
tokens=line.split()
36-
iftokens[0]in ['from','import']:
37-
completing_from=False
38-
iftokens[0]=='from':
39-
iflen(tokens)>3:
40-
if'.'incw:
41-
# This will result in a SyntaxError, so do not return
42-
# any matches
43-
returnlist()
44-
completing_from=True
45-
cw='%s.%s'% (tokens[1],cw)
46-
eliflen(tokens)==3:
47-
return ['import']
48-
49-
matches=list()
50-
fornameinmodules:
51-
ifnot (name.startswith(cw)andname.find('.',len(cw))==-1):
52-
continue
53-
ifcompleting_from:
54-
name=name[len(tokens[1])+1:]
55-
matches.append(name)
56-
returnmatches
57-
else:
36+
iftokens[0]notin ['from','import']:
5837
returnlist()
5938

39+
completing_from=False
40+
iftokens[0]=='from':
41+
iflen(tokens)>3:
42+
if'.'incw:
43+
# This will result in a SyntaxError, so do not return
44+
# any matches
45+
returnlist()
46+
completing_from=True
47+
cw='%s.%s'% (tokens[1],cw)
48+
eliflen(tokens)==3:
49+
return ['import']
50+
51+
matches=list()
52+
fornameinmodules:
53+
ifnot (name.startswith(cw)andname.find('.',len(cw))==-1):
54+
continue
55+
ifcompleting_from:
56+
name=name[len(tokens[1])+1:]
57+
matches.append(name)
58+
ifnotmatches:
59+
returnNone
60+
returnmatches
61+
6062

6163
deffind_modules(path):
6264
"""Find all modules (and packages) for a given directory."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp