mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
Fine-tune completion a bit.
This commit is contained in:
parent
6c89749f0a
commit
7924f07971
@ -562,10 +562,13 @@ class _PathCompleter:
|
||||
if os.path.isdir(path):
|
||||
files = glob.glob(os.path.join(path, "*"))
|
||||
prefix = txt
|
||||
elif os.path.isfile(path):
|
||||
prefix = os.path.dirname(txt)
|
||||
files = glob.glob(prefix+"/*")
|
||||
else:
|
||||
files = glob.glob(path+"*")
|
||||
prefix = os.path.dirname(txt)
|
||||
prefix = prefix.rstrip("/") or "./"
|
||||
prefix = prefix or "./"
|
||||
for f in files:
|
||||
display = os.path.join(prefix, os.path.basename(f))
|
||||
if os.path.isdir(f):
|
||||
|
0
test/completion/aaa
Normal file
0
test/completion/aaa
Normal file
0
test/completion/aab
Normal file
0
test/completion/aab
Normal file
0
test/completion/aac
Normal file
0
test/completion/aac
Normal file
@ -123,6 +123,17 @@ class uformat_flow(libpry.AutoTree):
|
||||
|
||||
|
||||
class uPathCompleter(libpry.AutoTree):
|
||||
def test_lookup_construction(self):
|
||||
c = console._PathCompleter()
|
||||
assert c.complete("/tm") == "/tmp/"
|
||||
c.reset()
|
||||
|
||||
assert c.complete("./completion/a") == "./completion/aaa"
|
||||
c.reset()
|
||||
assert c.complete("./completion/aaa") == "./completion/aaa"
|
||||
assert c.complete("./completion/aaa") == "./completion/aab"
|
||||
|
||||
|
||||
def test_completion(self):
|
||||
c = console._PathCompleter(True)
|
||||
c.reset()
|
||||
@ -152,6 +163,7 @@ class uPathCompleter(libpry.AutoTree):
|
||||
|
||||
|
||||
|
||||
|
||||
tests = [
|
||||
uformat_keyvals(),
|
||||
uformat_flow(),
|
||||
|
Loading…
Reference in New Issue
Block a user