From 06c1f175701eccc2fe2d3af242926f85a1fe958a Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sun, 12 Jul 2026 20:36:15 +0200 Subject: [PATCH] Use full compound extension (.md.gpg, .org.age, etc.) fileitemaction uses completeSuffix() to preserve the full extension. fileTypeFromExtension() recurses on compound extensions to detect frontmatter support from the inner extension. --- fileitemaction/denote_fileitemaction.cpp | 2 +- lib/denote_frontmatter.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fileitemaction/denote_fileitemaction.cpp b/fileitemaction/denote_fileitemaction.cpp index a2a8732..b5f9561 100644 --- a/fileitemaction/denote_fileitemaction.cpp +++ b/fileitemaction/denote_fileitemaction.cpp @@ -68,7 +68,7 @@ void DenoteFileItemAction::renameWithDenote(const KFileItemList &items, QWidget defaultTitle.replace(QLatin1Char('_'), QLatin1Char(' ')); // Try to extract title from frontmatter if applicable - const QString ext = QStringLiteral(".") + fi.suffix(); + const QString ext = QStringLiteral(".") + fi.completeSuffix(); Denote::FileType fileType = Denote::fileTypeFromExtension(ext); if (fileType != Denote::FileType::Unknown) { QFile file(path); diff --git a/lib/denote_frontmatter.cpp b/lib/denote_frontmatter.cpp index db60c73..a3eac83 100644 --- a/lib/denote_frontmatter.cpp +++ b/lib/denote_frontmatter.cpp @@ -8,12 +8,21 @@ namespace Denote { FileType fileTypeFromExtension(const QString &ext) { const QString lower = ext.toLower(); + // Check the full extension first, then the inner extension for compound types + // e.g. ".md.gpg" -> check ".md.gpg", then ".md" if (lower == QStringLiteral(".md") || lower == QStringLiteral(".markdown")) return FileType::MdYaml; if (lower == QStringLiteral(".org")) return FileType::Org; if (lower == QStringLiteral(".txt")) return FileType::Txt; + + // For compound extensions, check if the inner part is supported + int dot = lower.indexOf(QLatin1Char('.'), 1); + if (dot > 0) { + return fileTypeFromExtension(lower.left(dot)); + } + return FileType::Unknown; }