diff --git a/twander.py b/twander.py index 5c8275a..dca78b7 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ # For Updates See: http://www.tundraware.com/Software/twander PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.40 2003/01/02 21:20:40 tundra Exp $" +RCSID = "$Id: twander.py,v 2.41 2003/01/02 22:58:36 tundra Exp $" VERSION = RCSID.split()[2] @@ -314,9 +314,9 @@ wCMDKEY = "Configuration File Entry For: \'%s\' Has No Command Key Defined." wCONFOPEN = "Cannot Open Configuration File:\n%s\n\n%s" +wLINKBACK = "%s Points Back To Own Directory" wMOUSEBIND = "Cannot Rebind A Mouse Button Combination.\nIgnoring Line %s:\n\n%s" wNOCMDS = "Running With No Commands Defined!" -wSYMBACK = "Symbolic Link %s Points Back To Own Directory" wWARN = "WARNING" @@ -1425,8 +1425,6 @@ def DirListHandler(event): global UI - SAVE = TRUE - # Get current selection. If none, just return, otherwise process selected = UI.LastInSelection() if not selected: @@ -1436,18 +1434,12 @@ if os.path.isdir(os.path.join(UI.CurrentDir, selected)): - # If we're on Unix, don't follow symlinks pointing back to themselves + # On Unix, don't follow links pointing back to themselves if OSNAME == 'posix' and os.path.samefile(UI.CurrentDir, UI.CurrentDir + selected): - WrnMsg(wSYMBACK % (UI.CurrentDir + selected)) + WrnMsg(wLINKBACK % (UI.CurrentDir + selected[:-1])) return - # We don't push this selection on the stack if - # we are at root directory and user presses '..' - - if (selected == '..') and (UI.CurrentDir == os.path.abspath(PSEP)): - SAVE = FALSE - # Build full path name selected = os.path.join(os.path.abspath(UI.CurrentDir), selected) @@ -1466,7 +1458,7 @@ selected += PSEP # Load UI with new directory - LoadDirList(selected, save=SAVE) + LoadDirList(selected, save=TRUE) # Indicate that we entered a new directory this way. # This is a workaround for Tk madness. When this @@ -1533,16 +1525,22 @@ # Push last directory visited onto the visited stack - # Do not do this if we've been told not to OR if - # what we're about to save is the same as the top - # of the stack OR if the current directory is "" + # We do NOT save this to the stack if: + # + # 1) We've been told not to. - Passed when we're called (save=FALSE). + # 2) If we're trying to move into the current directory again. + # This can happen either when the user does a manual directory + # change or if they press ".." while in root. We don't + # actually want to save the directory until we *leave* it, + # otherwise we'll end up with a stack top and current + # directory which are the same, and we'll have to go + # back *twice* to move to the previous directory. - # If there is anything on the stack, see if last element - # matches what we're about to put there. - - if UI.LastDir and UI.LastDir[-1] == UI.CurrentDir: + # Are we trying to move back into same directory? + if os.path.abspath(UI.CurrentDir) == os.path.abspath(newdir): save = FALSE + # Now save if we're supposed to. if save and UI.CurrentDir: UI.LastDir.append(UI.CurrentDir)