mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 22:06:15 +00:00
Fix shortenng of file names in MakeDisplayPath.
It is not a good idea to slice an utf8 string at arbitrary offsets, we have to work on a docstring instead. We need unfortunately to switch back and forth between utf8 and docstring. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40149 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
33c8906f70
commit
337bfa6010
@ -791,25 +791,26 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold)
|
|||||||
return from_utf8(os::external_path(str));
|
return from_utf8(os::external_path(str));
|
||||||
|
|
||||||
string const prefix = ".../";
|
string const prefix = ".../";
|
||||||
string temp;
|
docstring dstr = from_utf8(str);
|
||||||
|
docstring temp;
|
||||||
|
|
||||||
while (str.length() > threshold)
|
while (dstr.length() > threshold)
|
||||||
str = split(str, temp, '/');
|
dstr = split(dstr, temp, '/');
|
||||||
|
|
||||||
// Did we shorten everything away?
|
// Did we shorten everything away?
|
||||||
if (str.empty()) {
|
if (dstr.empty()) {
|
||||||
// Yes, filename itself is too long.
|
// Yes, filename itself is too long.
|
||||||
// Pick the start and the end of the filename.
|
// Pick the start and the end of the filename.
|
||||||
str = onlyFileName(path);
|
dstr = from_utf8(onlyFileName(path));
|
||||||
string const head = str.substr(0, threshold / 2 - 3);
|
docstring const head = dstr.substr(0, threshold / 2 - 3);
|
||||||
|
|
||||||
string::size_type len = str.length();
|
docstring::size_type len = dstr.length();
|
||||||
string const tail =
|
docstring const tail =
|
||||||
str.substr(len - threshold / 2 - 2, len - 1);
|
dstr.substr(len - threshold / 2 - 2, len - 1);
|
||||||
str = head + "..." + tail;
|
dstr = head + from_ascii("...") + tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return from_utf8(os::external_path(prefix + str));
|
return from_utf8(os::external_path(prefix + to_utf8(dstr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ What's new
|
|||||||
|
|
||||||
- Remove annoying startup debug message.
|
- Remove annoying startup debug message.
|
||||||
|
|
||||||
|
- Fix display of file names that contain many non-ascii characters.
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION AND LOCALIZATION
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user