From dfaa7772df1854508196b340f3bf04aa4ca3b712 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 7 Aug 2017 20:01:24 +0800 Subject: [PATCH] bug-fix: use the default suffix from markdown suffix list --- src/vfilelist.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vfilelist.cpp b/src/vfilelist.cpp index a10a98aa..93db2852 100644 --- a/src/vfilelist.cpp +++ b/src/vfilelist.cpp @@ -219,9 +219,13 @@ void VFileList::newFile() } QList suffixes = vconfig.getDocSuffixes()[(int)DocType::Markdown]; + QString defaultSuf; QString suffixStr; for (auto const & suf : suffixes) { suffixStr += (suffixStr.isEmpty() ? suf : "/" + suf); + if (defaultSuf.isEmpty() || suf == "md") { + defaultSuf = suf; + } } QString info = tr("Create a note in %2.") @@ -229,7 +233,7 @@ void VFileList::newFile() info = info + "
" + tr("Note with name ending with \"%1\" will be treated as Markdown type.") .arg(suffixStr); QString text(tr("Note &name:")); - QString defaultText("new_note.md"); + QString defaultText = QString("new_note.%1").arg(defaultSuf); do { VNewFileDialog dialog(tr("Create Note"), info, text, defaultText, this); if (dialog.exec() == QDialog::Accepted) {