[Python-checkins] cpython (3.2): Issue #14937: Perform auto-completion of filenames in strings even for

martin.v.loewis python-checkins at python.org
Sun Jun 3 12:00:56 CEST 2012


http://hg.python.org/cpython/rev/41e85ac2ccef
changeset:   77322:41e85ac2ccef
branch:      3.2
parent:      77316:f927a5c6e4be
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Sun Jun 03 11:55:32 2012 +0200
summary:
  Issue #14937: Perform auto-completion of filenames in strings even for non-ASCII filenames.

files:
  Lib/idlelib/AutoComplete.py       |  11 +++++++++--
  Lib/idlelib/AutoCompleteWindow.py |   9 +++++++++
  Lib/idlelib/NEWS.txt              |   6 ++++++
  3 files changed, 24 insertions(+), 2 deletions(-)


diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/AutoComplete.py
@@ -124,13 +124,20 @@
         curline = self.text.get("insert linestart", "insert")
         i = j = len(curline)
         if hp.is_in_string() and (not mode or mode==COMPLETE_FILES):
+            # Find the beginning of the string
+            # fetch_completions will look at the file system to determine whether the
+            # string value constitutes an actual file name
+            # XXX could consider raw strings here and unescape the string value if it's
+            # not raw.
             self._remove_autocomplete_window()
             mode = COMPLETE_FILES
-            while i and curline[i-1] in FILENAME_CHARS:
+            # Find last separator or string start
+            while i and curline[i-1] not in "'\"" + SEPS:
                 i -= 1
             comp_start = curline[i:j]
             j = i
-            while i and curline[i-1] in FILENAME_CHARS + SEPS:
+            # Find string start
+            while i and curline[i-1] not in "'\"":
                 i -= 1
             comp_what = curline[i:j]
         elif hp.is_in_code() and (not mode or mode==COMPLETE_ATTRIBUTES):
diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/AutoCompleteWindow.py
--- a/Lib/idlelib/AutoCompleteWindow.py
+++ b/Lib/idlelib/AutoCompleteWindow.py
@@ -354,6 +354,15 @@
             # A modifier key, so ignore
             return
 
+        elif event.char:
+            # Regular character with a non-length-1 keycode
+            self._change_start(self.start + event.char)
+            self.lasttypedstart = self.start
+            self.listbox.select_clear(0, int(self.listbox.curselection()[0]))
+            self.listbox.select_set(self._binary_search(self.start))
+            self._selection_changed()
+            return "break"
+
         else:
             # Unknown event, close the window and let it through.
             self.hide_window()
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -1,3 +1,9 @@
+What's New in IDLE 3.2.4?
+=========================
+
+- Issue #14937: Perform auto-completion of filenames in strings even for
+  non-ASCII filenames.
+
 What's New in IDLE 3.2.3?
 =========================
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list