Skip to content

Commit

Permalink
fix #4: fail to open a document when the markdown reader is set to a …
Browse files Browse the repository at this point in the history
…command with arguments
  • Loading branch information
SZinedine committed Feb 27, 2024
1 parent dd47a56 commit 403d8b0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ void MainWindow::loadDocuments() {
ui->documentContentView->reset();
clearDocuments();

QString dataDirectory = Ui::Settings::loadDataDirectory();;
QString dataDirectory = Ui::Settings::loadDataDirectory();

if (dataDirectory.isEmpty() || !QDir(dataDirectory).exists()) {
onChangeDataDirAction();
return;
Expand Down Expand Up @@ -348,7 +349,16 @@ void MainWindow::openFile(QString path, QString editor) {
if (editor.isEmpty()) {
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
} else {
QProcess::startDetached(editor, { path });
editor = editor.simplified();
if (editor.indexOf(' ') == -1) {
QProcess::startDetached(editor, { path });
} else {
QStringList args = editor.split(" ");
const QString ed = args.at(0);
args.removeAt(0);
args.append(path);
QProcess::startDetached(ed, args);
}
}

Ui::Settings::addRecentFile(path);
Expand Down

0 comments on commit 403d8b0

Please sign in to comment.