Parcourir la source

fixed a bug in tab-completion

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1445 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen il y a 15 ans
Parent
commit
c2e90505e7
2 fichiers modifiés avec 10 ajouts et 4 suppressions
  1. 8 4
      src/bin/bindctl/bindcmd.py
  2. 2 0
      src/lib/python/isc/config/config_data.py

+ 8 - 4
src/bin/bindctl/bindcmd.py

@@ -326,7 +326,10 @@ class BindCmdInterpreter(Cmd):
             line = 'help'
         
         Cmd.onecmd(self, line)
-                    
+
+    def remove_prefix(self, list, prefix):
+        return [(val[len(prefix):]) for val in list]
+
     def complete(self, text, state):
         if 0 == state:
             text = text.strip()
@@ -342,9 +345,10 @@ class BindCmdInterpreter(Cmd):
                     if cmd.module == "config":
                         # grm text has been stripped of slashes...
                         my_text = self.location + "/" + cur_line.rpartition(" ")[2]
-                        print("[XX] completing config part")
-                        list = self.config_data.get_config_item_list(my_text.rpartition("/")[0])
-                        hints.extend([val for val in list if val.startswith(text)])
+                        list = self.config_data.get_config_item_list(my_text.rpartition("/")[0], True)
+                        hints.extend([val for val in list if val.startswith(my_text[1:])])
+                        # remove the common prefix from the hints so we don't get it twice
+                        hints = self.remove_prefix(hints, my_text.rpartition("/")[0])
             except CmdModuleNameFormatError:
                 if not text:
                     hints = self.get_module_names()

+ 2 - 0
src/lib/python/isc/config/config_data.py

@@ -401,6 +401,8 @@ class MultiConfigData:
            the identifier (up to the first /) is interpreted as the
            module name"""
         if identifier and identifier != "/":
+            if identifier.startswith("/"):
+                identifier = identifier[1:]
             spec = self.find_spec_part(identifier)
             return spec_name_list(spec, identifier + "/", recurse)
         else: