On Wed, Aug 11, 2010 at 1:58 AM, Bram Moolenaar <b...@moolenaar.net> wrote:
>
> The full path names are not nice.  Not only for the test but also for
> interactive use.  I think we should replace the current directory with
> "./" when possible.

Thanks for pointing this out.  Attached patch does the above, and test73
passes for both unix and msvc-vim with this patch.

I'm having trouble running test73 with djgpp vim because somehow it
failed at creating the "Xfind" directory.

I commented out the final ":qa!" in test73.vim, rerun the test and wait
until it stops at the end and issued

    :!mkdir foo

from inside the running djgpp-vim, which failed with error message:

    shell returned -1

Any idea why this could be?

Also:

    :pwd
    c:\src\vim\src

I was expecting it to be "c:\src\vim\src\testdir".

nazri

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
From 90e439bb7623a6108c7532fe3ab74a11d8c68f5c Mon Sep 17 00:00:00 2001
From: Nazri Ramliy <ayieh...@gmail.com>
Date: Wed, 11 Aug 2010 09:30:15 +0800
Subject: [PATCH] find completion: Be a bit more aggressive at shortening filenames

---
 src/misc1.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/src/misc1.c b/src/misc1.c
index fd4e4fe..afc970a 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9457,6 +9457,7 @@ uniquefy_paths(gap, pattern)
 	char_u	    *path = fnames[i];
 	int	    is_in_curdir;
 	char_u	    *dir_end = gettail(path);
+	char_u	    *short_name;
 
 	len = (int)STRLEN(path);
 	while (dir_end > path &&
@@ -9475,11 +9476,16 @@ uniquefy_paths(gap, pattern)
 	 * and it is not unique,
 	 * reduce it to ./{filename}
 	 *        FIXME ^ Is this portable?
+	 *
+	 * Note: If the full filename is /curdir/foo/bar/{filename}, we don't
+	 * want to shorten it to ./foo/bar/{filename} yet because 'path' might
+	 * contain "./ **", in which case the shortened filename could be shorter
+	 * than ./foo/bar/{filename}.
 	 */
 	if (is_in_curdir)
 	{
 	    char_u *rel_path;
-	    char_u *short_name = shorten_fname(path, curdir);
+	    short_name = shorten_fname(path, curdir);
 
 	    if (short_name == NULL)
 		short_name = path;
@@ -9533,6 +9539,34 @@ uniquefy_paths(gap, pattern)
 		    break;
 		}
 	}
+
+	if (mch_isFullName(path))
+	{
+	    /*
+	     * Last resort: shorten relative to curdir if possible.
+	     * 'possible' means:
+	     *
+	     *    1. It is under the current directory.
+	     *    2. The result is actually shorter than the original.
+	     *
+	     * Examples:
+	     *
+	     *	    Before                curdir        After
+	     *
+	     *	    /foo/bar/file.txt     /foo/bar      ./file.txt
+	     *      c:\foo\bar\file.txt   c:\foo\bar    .\file.txt
+	     *
+	     *      /file.txt             /             /file.txt
+	     *      c:\file.txt           c:\           \file.txt
+	     */
+	    short_name = shorten_fname(path, curdir);
+	    if (short_name != NULL && short_name > path + 1)
+	    {
+		STRMOVE(path + 2, short_name);
+		path[0] = '.';
+		path[1] = PATHSEP;
+	    }
+	}
     }
 
 theend:
-- 
1.7.2.1.6.g61bf12

Raspunde prin e-mail lui