From 7a0d3590e75382080e503a0fe80ee72fb84be82f Mon Sep 17 00:00:00 2001 From: jinjiaodawang Date: Wed, 28 Feb 2024 18:51:52 +0800 Subject: [PATCH 1/2] fix #988, run inverse search command as separated command and args --- pdf_viewer/main_widget.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp index bdd409023..25962cf95 100644 --- a/pdf_viewer/main_widget.cpp +++ b/pdf_viewer/main_widget.cpp @@ -1,4 +1,4 @@ -// deduplicate database code +// deduplicate database code // make sure jsons exported by previous sioyek versions can be imported // maybe: use a better method to handle deletion of canceled download portals // change find_closest_*_index and argminf to use the fact that the list is sorted and speed up the search (not important if there are not a ridiculous amount of highlight/bookmarks) @@ -4761,13 +4761,9 @@ std::wstring MainWidget::synctex_under_pos(WindowPos position) { 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 - res = QString("%1 %2 %3").arg(new_path, QString::number(line), QString::number(column)).toStdWString(); - QProcess::startDetached(command); + QString command = QString::fromStdWString(inverse_search_command).arg(new_path, line_string.c_str()); + QStringList args = QProcess::splitCommand(command); + QProcess::startDetached(args[0], args.mid(1)); } else { show_error_message(L"inverse_search_command is not set in prefs_user.config"); From 56d0e9f5e28e41cac659814800dd0a0ca22b3582 Mon Sep 17 00:00:00 2001 From: jinjiaodawang Date: Wed, 28 Feb 2024 19:21:10 +0800 Subject: [PATCH 2/2] Restore OS conditions for inverse search --- pdf_viewer/main_widget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp index 25962cf95..74999b983 100644 --- a/pdf_viewer/main_widget.cpp +++ b/pdf_viewer/main_widget.cpp @@ -4761,7 +4761,11 @@ std::wstring MainWidget::synctex_under_pos(WindowPos position) { std::string column_string = std::to_string(column); if (inverse_search_command.size() > 0) { - QString command = QString::fromStdWString(inverse_search_command).arg(new_path, line_string.c_str()); +#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 QStringList args = QProcess::splitCommand(command); QProcess::startDetached(args[0], args.mid(1)); }