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 { |
| 111 | /// them. |
111 | /// them. |
| 112 | public struct CloneSubtree: OrgCommand { |
112 | public struct CloneSubtree: OrgCommand { |
| 113 | let newID: @Sendable () -> String |
113 | 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 } |
| 115 | public var id: String { "org.subtree.clone" } |
115 | public var id: String { "org.subtree.clone" } |
| 116 | public var title: String { "Clone Subtree with Time Shift" } |
116 | public var title: String { "Clone Subtree with Time Shift" } |
| 117 | public func applies(in context: EditContext) -> Bool { entryHeading(at: context.caret, in: context.tree) != nil } |
117 | 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 { |
| 282 | public struct CreateID: OrgCommand { |
282 | public struct CreateID: OrgCommand { |
| 283 | let newID: @Sendable () -> String |
283 | let newID: @Sendable () -> String |
| 284 | |
284 | |
| 285 | public init(newID: @escaping @Sendable () -> String = { UUID().uuidString }) { |
285 | public init(newID: @escaping @Sendable () -> String = { UUID().uuidString.lowercased() }) { |
| 286 | self.newID = newID |
286 | self.newID = newID |
| 287 | } |
287 | } |
| 288 | |
288 | |
Tests/OrgCoreTests/LinkStoreTests.swift
+10
| @@ -209,4 +209,14 @@ struct LinkStoreTests { |
| 209 | } |
209 | } |
| 210 | #expect(ours == emacs) |
210 | #expect(ours == emacs) |
| 211 | } |
211 | } |
| |
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 | } |
| 212 | } |
222 | } |