From 33dce8511efa5432059e7593e20f0c53d7da080d Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 19 Feb 2026 18:56:25 -0500 Subject: [PATCH] macos: swiftlint 'trailing_semicolon' rule --- macos/.swiftlint.yml | 1 - macos/Sources/App/macOS/main.swift | 2 +- .../Terminal/BaseTerminalController.swift | 4 +- macos/Sources/Ghostty/Ghostty.Config.swift | 50 +++++++++---------- macos/Sources/Ghostty/Ghostty.Input.swift | 2 +- macos/Sources/Ghostty/Package.swift | 16 +++--- .../Ghostty/Surface View/InspectorView.swift | 2 +- .../Ghostty/Surface View/SurfaceView.swift | 10 ++-- .../Surface View/SurfaceView_AppKit.swift | 24 ++++----- .../Surface View/SurfaceView_UIKit.swift | 2 +- 10 files changed, 56 insertions(+), 57 deletions(-) diff --git a/macos/.swiftlint.yml b/macos/.swiftlint.yml index fc7ea7538..1c71146ef 100644 --- a/macos/.swiftlint.yml +++ b/macos/.swiftlint.yml @@ -24,7 +24,6 @@ disabled_rules: - orphaned_doc_comment - shorthand_operator - switch_case_alignment - - trailing_semicolon - trailing_whitespace - unneeded_synthesized_initializer - unused_closure_parameter diff --git a/macos/Sources/App/macOS/main.swift b/macos/Sources/App/macOS/main.swift index ad32f4e70..400f91c22 100644 --- a/macos/Sources/App/macOS/main.swift +++ b/macos/Sources/App/macOS/main.swift @@ -28,6 +28,6 @@ if ghostty_init(UInt(CommandLine.argc), CommandLine.unsafeArgv) != GHOSTTY_SUCCE // This will run the CLI action and exit if one was specified. A CLI // action is a command starting with a `+`, such as `ghostty +boo`. -ghostty_cli_try_action(); +ghostty_cli_try_action() _ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index f27874207..87e63c348 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -530,14 +530,14 @@ class BaseTerminalController: NSWindowController, // then we let it stay that way. x: if newFrame.origin.x < visibleFrame.origin.x { if let savedFrame, savedFrame.window.origin.x < savedFrame.screen.origin.x { - break x; + break x } newFrame.origin.x = visibleFrame.origin.x } y: if newFrame.origin.y < visibleFrame.origin.y { if let savedFrame, savedFrame.window.origin.y < savedFrame.screen.origin.y { - break y; + break y } newFrame.origin.y = visibleFrame.origin.y diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index 7acf44aff..3d3219663 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -22,7 +22,7 @@ extension Ghostty { var errors: [String] { guard let cfg = self.config else { return [] } - var diags: [String] = []; + var diags: [String] = [] let diagsCount = ghostty_config_diagnostics_count(cfg) for i in 0.. 0 { logger.warning("config error: \(diagsCount) configuration errors on reload") - var diags: [String] = []; + var diags: [String] = [] for i in 0.. Bool { switch self { - case .top_left, .top_center, .top_right: return true; - default: return false; + case .top_left, .top_center, .top_right: return true + default: return false } } func bottom() -> Bool { switch self { - case .bottom_left, .bottom_center, .bottom_right: return true; - default: return false; + case .bottom_left, .bottom_center, .bottom_right: return true + default: return false } } func left() -> Bool { switch self { - case .top_left, .bottom_left: return true; - default: return false; + case .top_left, .bottom_left: return true + default: return false } } func right() -> Bool { switch self { - case .top_right, .bottom_right: return true; - default: return false; + case .top_right, .bottom_right: return true + default: return false } } } diff --git a/macos/Sources/Ghostty/Ghostty.Input.swift b/macos/Sources/Ghostty/Ghostty.Input.swift index 563e4a794..27f4d05dd 100644 --- a/macos/Sources/Ghostty/Ghostty.Input.swift +++ b/macos/Sources/Ghostty/Ghostty.Input.swift @@ -49,7 +49,7 @@ extension Ghostty { /// Returns the event modifier flags set for the Ghostty mods enum. static func eventModifierFlags(mods: ghostty_input_mods_e) -> NSEvent.ModifierFlags { - var flags = NSEvent.ModifierFlags(rawValue: 0); + var flags = NSEvent.ModifierFlags(rawValue: 0) if mods.rawValue & GHOSTTY_MODS_SHIFT.rawValue != 0 { flags.insert(.shift) } if mods.rawValue & GHOSTTY_MODS_CTRL.rawValue != 0 { flags.insert(.control) } if mods.rawValue & GHOSTTY_MODS_ALT.rawValue != 0 { flags.insert(.option) } diff --git a/macos/Sources/Ghostty/Package.swift b/macos/Sources/Ghostty/Package.swift index 41dcfad28..bdb64a6b5 100644 --- a/macos/Sources/Ghostty/Package.swift +++ b/macos/Sources/Ghostty/Package.swift @@ -198,13 +198,13 @@ extension Ghostty { static func from(direction: ghostty_action_resize_split_direction_e) -> Self? { switch direction { case GHOSTTY_RESIZE_SPLIT_UP: - return .up; + return .up case GHOSTTY_RESIZE_SPLIT_DOWN: - return .down; + return .down case GHOSTTY_RESIZE_SPLIT_LEFT: - return .left; + return .left case GHOSTTY_RESIZE_SPLIT_RIGHT: - return .right; + return .right default: return nil } @@ -213,13 +213,13 @@ extension Ghostty { func toNative() -> ghostty_action_resize_split_direction_e { switch self { case .up: - return GHOSTTY_RESIZE_SPLIT_UP; + return GHOSTTY_RESIZE_SPLIT_UP case .down: - return GHOSTTY_RESIZE_SPLIT_DOWN; + return GHOSTTY_RESIZE_SPLIT_DOWN case .left: - return GHOSTTY_RESIZE_SPLIT_LEFT; + return GHOSTTY_RESIZE_SPLIT_LEFT case .right: - return GHOSTTY_RESIZE_SPLIT_RIGHT; + return GHOSTTY_RESIZE_SPLIT_RIGHT } } } diff --git a/macos/Sources/Ghostty/Surface View/InspectorView.swift b/macos/Sources/Ghostty/Surface View/InspectorView.swift index 076a465f7..e7320c782 100644 --- a/macos/Sources/Ghostty/Surface View/InspectorView.swift +++ b/macos/Sources/Ghostty/Surface View/InspectorView.swift @@ -309,7 +309,7 @@ extension Ghostty { } override func flagsChanged(with event: NSEvent) { - let mod: UInt32; + let mod: UInt32 switch event.keyCode { case 0x39: mod = GHOSTTY_MODS_CAPS.rawValue case 0x38, 0x3C: mod = GHOSTTY_MODS_SHIFT.rawValue diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index 2cc28d836..fce8f3f4b 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -221,7 +221,7 @@ extension Ghostty { // because we want to keep our focused surface dark even if we don't have window // focus. if isSplit && !surfaceFocus { - let overlayOpacity = ghostty.config.unfocusedSplitOpacity; + let overlayOpacity = ghostty.config.unfocusedSplitOpacity if overlayOpacity > 0 { Rectangle() .fill(ghostty.config.unfocusedSplitFill) @@ -328,15 +328,15 @@ extension Ghostty { lastSize = geoSize } - return true; + return true } } // Hidden depending on overlay config switch overlay { - case .never: return true; - case .always: return false; - case .after_first: return lastSize == nil; + case .never: return true + case .always: return false + case .after_first: return lastSize == nil } } diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index 9084d0e2e..fab3ad8e7 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -991,8 +991,8 @@ extension Ghostty { if precision { // We do a 2x speed multiplier. This is subjective, it "feels" better to me. - x *= 2; - y *= 2; + x *= 2 + y *= 2 // TODO(mitchellh): do we have to scale the x/y here by window scale factor? } @@ -1303,7 +1303,7 @@ extension Ghostty { } override func flagsChanged(with event: NSEvent) { - let mod: UInt32; + let mod: UInt32 switch event.keyCode { case 0x39: mod = GHOSTTY_MODS_CAPS.rawValue case 0x38, 0x3C: mod = GHOSTTY_MODS_SHIFT.rawValue @@ -1330,13 +1330,13 @@ extension Ghostty { let sidePressed: Bool switch event.keyCode { case 0x3C: - sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERSHIFTKEYMASK) != 0; + sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERSHIFTKEYMASK) != 0 case 0x3E: - sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERCTLKEYMASK) != 0; + sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERCTLKEYMASK) != 0 case 0x3D: - sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERALTKEYMASK) != 0; + sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERALTKEYMASK) != 0 case 0x36: - sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERCMDKEYMASK) != 0; + sidePressed = event.modifierFlags.rawValue & UInt(NX_DEVICERCMDKEYMASK) != 0 default: sidePressed = true } @@ -1388,7 +1388,7 @@ extension Ghostty { // since we always have a primary font. The only scenario this doesn't // work is if someone is using a non-CoreText build which would be // unofficial. - var attributes: [ NSAttributedString.Key: Any ] = [:]; + var attributes: [ NSAttributedString.Key: Any ] = [:] if let fontRaw = ghostty_surface_quicklook_font(surface) { // Memory management here is wonky: ghostty_surface_quicklook_font // will create a copy of a CTFont, Swift will auto-retain the @@ -1401,7 +1401,7 @@ extension Ghostty { // Ghostty coordinate system is top-left, convert to bottom-left for AppKit let pt = NSPoint(x: text.tl_px_x, y: frame.size.height - text.tl_px_y) let str = NSAttributedString.init(string: String(cString: text.text), attributes: attributes) - self.showDefinition(for: str, at: pt); + self.showDefinition(for: str, at: pt) } override func menu(for event: NSEvent) -> NSMenu? { @@ -1830,7 +1830,7 @@ extension Ghostty.SurfaceView: NSTextInputClient { // since we always have a primary font. The only scenario this doesn't // work is if someone is using a non-CoreText build which would be // unofficial. - var attributes: [ NSAttributedString.Key: Any ] = [:]; + var attributes: [ NSAttributedString.Key: Any ] = [:] if let fontRaw = ghostty_surface_quicklook_font(surface) { // Memory management here is wonky: ghostty_surface_quicklook_font // will create a copy of a CTFont, Swift will auto-retain the @@ -1868,8 +1868,8 @@ extension Ghostty.SurfaceView: NSTextInputClient { if ghostty_surface_read_selection(surface, &text) { // The -2/+2 here is subjective. QuickLook seems to offset the rectangle // a bit and I think these small adjustments make it look more natural. - x = text.tl_px_x - 2; - y = text.tl_px_y + 2; + x = text.tl_px_x - 2 + y = text.tl_px_y + 2 // Free our text ghostty_surface_free_text(surface, &text) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift index 3b1c63d57..8e8a93b93 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift @@ -81,7 +81,7 @@ extension Ghostty { // TODO return } - self.surface = surface; + self.surface = surface } required init?(coder: NSCoder) {