Fix SwiftFormat trailing whitespace

This commit is contained in:
Peter Steinberger 2025-05-27 01:23:39 +02:00
parent f6e9cbc7b9
commit a1505f3469

View file

@ -283,7 +283,7 @@ struct ImageCommand: ParsableCommand {
do { do {
let semaphore = DispatchSemaphore(value: 0) let semaphore = DispatchSemaphore(value: 0)
var captureError: Error? var captureError: Error?
Task { Task {
do { do {
try await captureDisplayWithScreenCaptureKit(displayID, to: path) try await captureDisplayWithScreenCaptureKit(displayID, to: path)
@ -292,9 +292,9 @@ struct ImageCommand: ParsableCommand {
} }
semaphore.signal() semaphore.signal()
} }
semaphore.wait() semaphore.wait()
if let error = captureError { if let error = captureError {
throw error throw error
} }
@ -302,19 +302,19 @@ struct ImageCommand: ParsableCommand {
throw CaptureError.captureCreationFailed throw CaptureError.captureCreationFailed
} }
} }
private func captureDisplayWithScreenCaptureKit(_ displayID: CGDirectDisplayID, to path: String) async throws { private func captureDisplayWithScreenCaptureKit(_ displayID: CGDirectDisplayID, to path: String) async throws {
// Get available content // Get available content
let availableContent = try await SCShareableContent.current let availableContent = try await SCShareableContent.current
// Find the display by ID // Find the display by ID
guard let scDisplay = availableContent.displays.first(where: { $0.displayID == displayID }) else { guard let scDisplay = availableContent.displays.first(where: { $0.displayID == displayID }) else {
throw CaptureError.captureCreationFailed throw CaptureError.captureCreationFailed
} }
// Create content filter for the entire display // Create content filter for the entire display
let filter = SCContentFilter(display: scDisplay, excludingWindows: []) let filter = SCContentFilter(display: scDisplay, excludingWindows: [])
// Configure capture settings // Configure capture settings
let configuration = SCStreamConfiguration() let configuration = SCStreamConfiguration()
configuration.width = scDisplay.width configuration.width = scDisplay.width
@ -322,13 +322,13 @@ struct ImageCommand: ParsableCommand {
configuration.backgroundColor = .black configuration.backgroundColor = .black
configuration.shouldBeOpaque = true configuration.shouldBeOpaque = true
configuration.showsCursor = true configuration.showsCursor = true
// Capture the image // Capture the image
let image = try await SCScreenshotManager.captureImage( let image = try await SCScreenshotManager.captureImage(
contentFilter: filter, contentFilter: filter,
configuration: configuration configuration: configuration
) )
try saveImage(image, to: path) try saveImage(image, to: path)
} }
@ -336,7 +336,7 @@ struct ImageCommand: ParsableCommand {
do { do {
let semaphore = DispatchSemaphore(value: 0) let semaphore = DispatchSemaphore(value: 0)
var captureError: Error? var captureError: Error?
Task { Task {
do { do {
try await captureWindowWithScreenCaptureKit(window, to: path) try await captureWindowWithScreenCaptureKit(window, to: path)
@ -345,9 +345,9 @@ struct ImageCommand: ParsableCommand {
} }
semaphore.signal() semaphore.signal()
} }
semaphore.wait() semaphore.wait()
if let error = captureError { if let error = captureError {
throw error throw error
} }
@ -355,19 +355,19 @@ struct ImageCommand: ParsableCommand {
throw CaptureError.windowCaptureFailed throw CaptureError.windowCaptureFailed
} }
} }
private func captureWindowWithScreenCaptureKit(_ window: WindowData, to path: String) async throws { private func captureWindowWithScreenCaptureKit(_ window: WindowData, to path: String) async throws {
// Get available content // Get available content
let availableContent = try await SCShareableContent.current let availableContent = try await SCShareableContent.current
// Find the window by ID // Find the window by ID
guard let scWindow = availableContent.windows.first(where: { $0.windowID == window.windowId }) else { guard let scWindow = availableContent.windows.first(where: { $0.windowID == window.windowId }) else {
throw CaptureError.windowNotFound throw CaptureError.windowNotFound
} }
// Create content filter for the specific window // Create content filter for the specific window
let filter = SCContentFilter(desktopIndependentWindow: scWindow) let filter = SCContentFilter(desktopIndependentWindow: scWindow)
// Configure capture settings // Configure capture settings
let configuration = SCStreamConfiguration() let configuration = SCStreamConfiguration()
configuration.width = Int(window.bounds.width) configuration.width = Int(window.bounds.width)
@ -375,13 +375,13 @@ struct ImageCommand: ParsableCommand {
configuration.backgroundColor = .clear configuration.backgroundColor = .clear
configuration.shouldBeOpaque = true configuration.shouldBeOpaque = true
configuration.showsCursor = false configuration.showsCursor = false
// Capture the image // Capture the image
let image = try await SCScreenshotManager.captureImage( let image = try await SCScreenshotManager.captureImage(
contentFilter: filter, contentFilter: filter,
configuration: configuration configuration: configuration
) )
try saveImage(image, to: path) try saveImage(image, to: path)
} }