Skip to content

Commit

Permalink
Add targetDescriptor to scripting hook events
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Dec 21, 2024
1 parent 974edb9 commit a0912ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CotEditor/Sources/Setting Managers/ScriptManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ final class ScriptManager: NSObject, NSFilePresenter, @unchecked Sendable {

guard let scripts = await self.scriptHandlersTable[eventType], !scripts.isEmpty else { return }

// Create an Apple event caused by the given `Document`.
let documentDescriptor = documentSpecifier.descriptor ?? NSAppleEventDescriptor(string: "BUG: document.objectSpecifier.descriptor was nil")
let event = NSAppleEventDescriptor(eventClass: "cEd1",
eventID: eventType.eventID,
targetDescriptor: nil,
targetDescriptor: .currentProcess(),
returnID: AEReturnID(kAutoGenerateReturnID),
transactionID: AETransactionID(kAnyTransactionID))
event.setParam(documentDescriptor, forKeyword: keyDirectObject)

let documentDescriptor = documentSpecifier.descriptor ?? NSAppleEventDescriptor(string: "BUG: document.objectSpecifier.descriptor was nil")
event.setParam(documentDescriptor, forKeyword: AEKeyword(keyDirectObject))

await self.dispatch(event, handlers: scripts)
}
Expand Down

0 comments on commit a0912ac

Please sign in to comment.