summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2012-06-03 00:24:21 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2012-06-03 00:24:21 (GMT)
commit361baaddcf11b3d51430491fba86a41c19d0d76f (patch)
tree043f8fb8ced601bb71ed5e68e4120a42715a8c05
parent07ea53cb218812404cdbde820647ce6e4b2d0f8e (diff)
parenta948c79ad42f25be575946e0cd45cf90d8f89385 (diff)
downloadcpython-361baaddcf11b3d51430491fba86a41c19d0d76f.zip
cpython-361baaddcf11b3d51430491fba86a41c19d0d76f.tar.gz
cpython-361baaddcf11b3d51430491fba86a41c19d0d76f.tar.bz2
Merge with 3.2 #10365
-rw-r--r--Lib/idlelib/IOBinding.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index 3c0995a..9528c9a 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -157,35 +157,32 @@ class IOBinding:
def open(self, event=None, editFile=None):
flist = self.editwin.flist
+ # Save in case parent window is closed (ie, during askopenfile()).
if flist:
if not editFile:
filename = self.askopenfile()
else:
filename=editFile
if filename:
- # If the current window has no filename and hasn't been
- # modified, we replace its contents (no loss). Otherwise
- # we open a new window. But we won't replace the
- # shell window (which has an interp(reter) attribute), which
- # gets set to "not modified" at every new prompt.
- # Also, make sure the current window has not been closed,
- # since it can be closed during the Open File dialog.
- try:
- interp = self.editwin.interp
- except AttributeError:
- interp = None
-
- if self.editwin and not self.filename and \
- self.get_saved() and not interp:
+ # If editFile is valid and already open, flist.open will
+ # shift focus to its existing window.
+ # If the current window exists and is a fresh unnamed,
+ # unmodified editor window (not an interpreter shell),
+ # pass self.loadfile to flist.open so it will load the file
+ # in the current window (if the file is not already open)
+ # instead of a new window.
+ if (self.editwin and
+ not getattr(self.editwin, 'interp', None) and
+ not self.filename and
+ self.get_saved()):
flist.open(filename, self.loadfile)
else:
flist.open(filename)
else:
if self.text:
self.text.focus_set()
-
return "break"
- #
+
# Code for use outside IDLE:
if self.get_saved():
reply = self.maybesave()