Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote SyncTeX path to allow for whitespace #1167

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions pdf_viewer/main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4811,32 +4811,29 @@ std::wstring MainWidget::synctex_under_pos(WindowPos position) {
if (column < 0) column = 0;
int tag = synctex_node_tag(node);
const char* file_name = synctex_scanner_get_name(scanner, tag);
QString new_path;
#ifdef Q_OS_WIN
// the path returned by synctex is formatted in unix style, for example it is something like this
// in windows: d:/some/path/file.pdf
// this doesn't work with Vimtex for some reason, so here we have to convert the path separators
// to windows style and make sure the driver letter is capitalized
// the path returned by synctex is formatted in unix style, for example it is something like this
// in windows: d:/some/path/file.pdf
// this doesn't work with Vimtex for some reason, so here we have to convert the path separators
// to native style and if on windows ensure the drive letter is capitalized
QDir file_path = QDir(file_name);
new_path = QDir::toNativeSeparators(file_path.absolutePath());
QString new_path = QDir::toNativeSeparators(file_path.absolutePath());

#ifdef Q_OS_WIN
new_path[0] = new_path[0].toUpper();
if (VIMTEX_WSL_FIX) {
new_path = file_name;
}

#else
new_path = file_name;
#endif

// quote to allow for whitespace in path
new_path.prepend("\"");
new_path.append("\"");

std::string line_string = std::to_string(line);
std::string column_string = std::to_string(column);

if (inverse_search_command.size() > 0) {
#ifdef Q_OS_WIN
QString command = QString::fromStdWString(inverse_search_command).arg(new_path, line_string.c_str(), column_string.c_str());
#else
QString command = QString::fromStdWString(inverse_search_command).arg(file_name, line_string.c_str(), column_string.c_str());
#endif
QString command = QString::fromStdWString(inverse_search_command).arg(new_path, line_string.c_str(), column_string.c_str());
QStringList args = QProcess::splitCommand(command);
QProcess::startDetached(args[0], args.mid(1));
}
Expand Down