aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/console.py5
-rw-r--r--test/completion/aaa0
-rw-r--r--test/completion/aab0
-rw-r--r--test/completion/aac0
-rw-r--r--test/test_console.py12
5 files changed, 16 insertions, 1 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py
index eac2823a..0f5a9e37 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -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):
diff --git a/test/completion/aaa b/test/completion/aaa
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/completion/aaa
diff --git a/test/completion/aab b/test/completion/aab
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/completion/aab
diff --git a/test/completion/aac b/test/completion/aac
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/completion/aac
diff --git a/test/test_console.py b/test/test_console.py
index 9236baff..98a1270f 100644
--- a/test/test_console.py
+++ b/test/test_console.py
@@ -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(),