From 67e0e025a09d91da238475e2d1b9b1d34779f312 Mon Sep 17 00:00:00 2001 From: Vladimir Gusev Date: Fri, 22 Aug 2025 03:07:36 +0300 Subject: [PATCH] Prevent `Makefile` from being renamed to `Makefile.make` during save --- .../CodeFileDocument/CodeFileDocument.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift b/CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift index bab03a52f..97c2b0729 100644 --- a/CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift +++ b/CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift @@ -303,6 +303,16 @@ final class CodeFileDocument: NSDocument, ObservableObject { } } + override func fileNameExtension( + forType typeName: String, + saveOperation: NSDocument.SaveOperationType + ) -> String? { + guard let fileTypeName = Self.fileTypeExtension[typeName] else { + return super.fileNameExtension(forType: typeName, saveOperation: saveOperation) + } + return fileTypeName + } + /// Determines the code language of the document. /// Use ``CodeFileDocument/language`` for the default value before using this. That property is used to override /// the file's language. @@ -332,3 +342,10 @@ extension CodeFileDocument: LanguageServerDocument { fileURL?.lspURI } } + +private extension CodeFileDocument { + + static let fileTypeExtension: [String: String?] = [ + "public.make-source": nil + ] +}