]> git.lyx.org Git - lyx.git/commitdiff
Fix shortenng of file names in MakeDisplayPath: it is not a good idea to slice an...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 6 Nov 2011 22:36:14 +0000 (22:36 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 6 Nov 2011 22:36:14 +0000 (22:36 +0000)
This is a candidate for branch too, although the bug is minor.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40149 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/filetools.cpp

index bb531b807ca5d9cd0d1351e5cc9680d8b3250327..5891e79fec62c6b89346ed3e611a265e8a7bc1ca 100644 (file)
@@ -802,25 +802,26 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold)
                return from_utf8(os::external_path(str));
 
        string const prefix = ".../";
-       string temp;
+       docstring dstr = from_utf8(str);
+       docstring temp;
 
-       while (str.length() > threshold)
-               str = split(str, temp, '/');
+       while (dstr.length() > threshold)
+               dstr = split(dstr, temp, '/');
 
        // Did we shorten everything away?
-       if (str.empty()) {
+       if (dstr.empty()) {
                // Yes, filename itself is too long.
                // Pick the start and the end of the filename.
-               str = onlyFileName(path);
-               string const head = str.substr(0, threshold / 2 - 3);
+               dstr = from_utf8(onlyFileName(path));
+               docstring const head = dstr.substr(0, threshold / 2 - 3);
 
-               string::size_type len = str.length();
-               string const tail =
-                       str.substr(len - threshold / 2 - 2, len - 1);
-               str = head + "..." + tail;
+               docstring::size_type len = dstr.length();
+               docstring const tail =
+                       dstr.substr(len - threshold / 2 - 2, len - 1);
+               dstr = head + from_ascii("...") + tail;
        }
 
-       return from_utf8(os::external_path(prefix + str));
+       return from_utf8(os::external_path(prefix + to_utf8(dstr)));
 }