krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 578d60d689

578d60d689035eefc4bab8e330813a509da32adb

parent: 198b949ff1

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-08 03:51 UTC

Create lowercase IDs, as org-id-uuid does

Create ID and cloned subtrees now get lowercase UUIDs.

Layout: unified · split

Sources/OrgCore/Commands/SubtreeCommands.swift +1 −1
@@ -111,7 +111,7 @@ public struct PasteSubtree: OrgCommand {
111111/// them.
112112public struct CloneSubtree: OrgCommand {
113113 let newID: @Sendable () -> String
114 public init(newID: @escaping @Sendable () -> String = { UUID().uuidString }) { self.newID = newID }
114 public init(newID: @escaping @Sendable () -> String = { UUID().uuidString.lowercased() }) { self.newID = newID }
115115 public var id: String { "org.subtree.clone" }
116116 public var title: String { "Clone Subtree with Time Shift" }
117117 public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil }
Sources/OrgCore/Links/LinkStore.swift +1 −1
@@ -282,7 +282,7 @@ public struct InsertLink: OrgCommand {
282282public struct CreateID: OrgCommand {
283283 let newID: @Sendable () -> String
284284
285 public init(newID: @escaping @Sendable () -> String = { UUID().uuidString }) {
285 public init(newID: @escaping @Sendable () -> String = { UUID().uuidString.lowercased() }) {
286286 self.newID = newID
287287 }
288288
Tests/OrgCoreTests/LinkStoreTests.swift +10
@@ -209,4 +209,14 @@ struct LinkStoreTests {
209209 }
210210 #expect(ours == emacs)
211211 }
212
213 @Test(.enabled(if: oracle))
214 func createdIDsAreLowercaseUUIDsLikeOrgID() throws {
215 let uuid = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
216 let emacs = try EmacsOracle.evaluate("* A\n", "(list (progn (require 'org-id) (org-id-uuid)))")
217 #expect(emacs.first?.range(of: uuid, options: .regularExpression) != nil, "\(emacs)")
218 let text = runCommand(CreateID(), "* A\n", caret: 0).text
219 let id = try #require(text.firstMatch(of: /:ID: +(\S+)/)?.1)
220 #expect(String(id).range(of: uuid, options: .regularExpression) != nil, "\(text)")
221 }
212222}