--- VFSFileChooserDialog.java.orig	Tue Jan 14 09:56:05 2003
+++ VFSFileChooserDialog.java	Sun Jan 12 01:56:19 2003
@@ -28,6 +28,7 @@
 import java.awt.event.*;
 import java.awt.*;
 import java.io.File;
+import java.io.IOException;
 import java.util.*;
 import org.gjt.sp.jedit.gui.EnhancedDialog;
 import org.gjt.sp.jedit.io.*;
@@ -159,6 +160,54 @@
 		super.dispose();
 	} //}}}
 
+	//{{{ changeDirectory() method
+	private boolean changeDirectory()
+	{
+		String filename = filenameField.getText();
+		String path = MiscUtilities.constructPath(
+			browser.getDirectory(), filename);
+		VFS vfs = VFSManager.getVFSForPath(path);
+
+		if(vfs == null)
+			return false;
+
+		try
+		{
+			String sep = (new Character(vfs.getFileSeparator()).toString());
+			if(!path.endsWith(sep))
+				path += sep;
+
+			Object session = vfs.createVFSSession(path,this);
+			VFS.DirectoryEntry entry = vfs._getDirectoryEntry(
+				session, path, this);
+			if(entry.type == VFS.DirectoryEntry.DIRECTORY)
+			{
+				browser.setDirectory(path);
+				filenameField.setText("");
+				return true;
+			}
+		}
+		catch(IOException ioe)
+		{
+			// XXX remove me later
+			Log.log(Log.ERROR,
+				VFSFileChooserDialog.class,
+				"Error determining if \"" 
+					+ path + "\" is a directory: " 
+					+ ioe.toString());
+		}
+		catch(NullPointerException npe)
+		{
+			// XXX remove me later
+			Log.log(Log.DEBUG,
+				VFSFileChooserDialog.class,
+				"NPE determing if \"" + path + "\" is a directory");
+		}
+
+		return false;
+	}
+	//}}}
+
 	//{{{ ok() method
 	public void ok()
 	{
@@ -182,6 +231,12 @@
 				}
 				else if(browser.getMode() == VFSBrowser.BROWSER_DIALOG)
 				{
+
+					// if directory name in filename field
+					// change to that directory
+					if(changeDirectory())
+						return;
+
 					Hashtable props = new Hashtable();
 					props.put(Buffer.ENCODING,browser.currentEncoding);
 					jEdit.openFile(browser.getView(),
@@ -213,6 +268,11 @@
 
 		if(browser.getMode() == VFSBrowser.SAVE_DIALOG)
 		{
+			// if directory name in filename field
+			// change to that directory
+			if(changeDirectory())
+				return;
+
 			if(!MiscUtilities.isURL(directory)
 				&& !MiscUtilities.isURL(filename))
 			{
