[RFC][PATCH] Change to GuiView::goToFileRow
Enrico Forestieri
forenr at lyx.org
Sat Feb 15 12:10:05 UTC 2020
On Fri, Feb 14, 2020 at 09:00:48PM +0100, Stephan Witt wrote:
> Hi all,
>
> I’ve a problem in LyX master with reverse search I don’t have in 2.3.x.
> Unfortunately I cannot see the difference in LyX code causing it.
>
> The situation is: on Mac the directory /var is an symlink to private/var.
> So the temporary files are with real path below /private/var/. The SyncTex
> file contains this path name, e.g.
>
> Input:1:/private/var/folders/1x/zm63s22x7s591xrlgm4rl9v40000gn/T/lyx_tmpdir.pfyyHSvCxUfX/lyx_tmpbuf0/./Tutorial.tex
>
> But the reverse search script is called with file name:
>
> /var/folders/1x/zm63s22x7s591xrlgm4rl9v40000gn/T/lyx_tmpdir.pfyyHSvCxUfX/lyx_tmpbuf0/Tutorial.tex
>
> Some normalization happens here. I’ve changed the lyxeditor script to see the
> call. It’s not
> the operation in line 85 (were sed is used to remove /private from path name).
>
> To make the GuiView::goToFileRow() implementation more robust I came to the
> attached patch.
>
> I’m confident it cannot hurt. But as I don’t understand the situation
> completely I ask for comments.
>
> Stephan
> [-- mutt.octet.filter file type: "unified diff output, ASCII text" --]
>
> diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
> index eec1b7ae6e..f215389adc 100644
> --- a/src/frontends/qt/GuiView.cpp
> +++ b/src/frontends/qt/GuiView.cpp
> @@ -3675,9 +3675,17 @@ bool GuiView::goToFileRow(string const & argument)
> LYXERR0("Wrong argument: " << argument);
> return false;
> }
> + LYXERR(Debug::FILES, "goToFileRow: row " << row << " in file " << file_name);
> Buffer * buf = 0;
> string const abstmp = package().temp_dir().absFileName();
> - string const realtmp = package().temp_dir().realPath();
> + string realtmp = package().temp_dir().realPath();
> +
> +#ifdef Q_OS_MAC
> + if (realtmp == abstmp &&
> + os::path_prefix_is(realtmp,"/private/var/",os::CASE_ADJUSTED)) {
> + realtmp = realtmp.substr(8);
> + }
> +#endif
> // We have to use os::path_prefix_is() here, instead of
> // simply prefixIs(), because the file name comes from
> // an external application and may need case adjustment.
I think I don't understand what is the problem. The code snippet you are
changing is as follows:
...
string const abstmp = package().temp_dir().absFileName();
string const realtmp = package().temp_dir().realPath();
// We have to use os::path_prefix_is() here, instead of
// simply prefixIs(), because the file name comes from
// an external application and may need case adjustment.
if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
|| os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
// Needed by inverse dvi search. If it is a file
// in tmpdir, call the apropriated function.
// If tmpdir is a symlink, we may have the real
// path passed back, so we correct for that.
if (!prefixIs(file_name, abstmp))
file_name = subst(file_name, realtmp, abstmp);
buf = theBufferList().getBufferFromTmp(file_name);
} else {
...
meaning that file_name is compared with both abstmp (with possibly
unexpanded symlink) and realtmp (with expanded symlink). Hence both
cases are considered and your patch should not be needed.
--
Enrico
More information about the lyx-devel
mailing list