macos: swiftlint 'trailing_semicolon' rule

This commit is contained in:
Jon Parise
2026-02-19 18:56:25 -05:00
parent 6af959920e
commit 33dce8511e
10 changed files with 56 additions and 57 deletions

View File

@@ -24,7 +24,6 @@ disabled_rules:
- orphaned_doc_comment
- shorthand_operator
- switch_case_alignment
- trailing_semicolon
- trailing_whitespace
- unneeded_synthesized_initializer
- unused_closure_parameter

View File

@@ -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)

View File

@@ -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

View File

@@ -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..<diagsCount {
let diag = ghostty_config_get_diagnostic(cfg, UInt32(i))
@@ -73,10 +73,10 @@ extension Ghostty {
// We only load CLI args when not running in Xcode because in Xcode we
// pass some special parameters to control the debugger.
if !isRunningInXcode() {
ghostty_config_load_cli_args(cfg);
ghostty_config_load_cli_args(cfg)
}
ghostty_config_load_recursive_files(cfg);
ghostty_config_load_recursive_files(cfg)
#endif
// TODO: we'd probably do some config loading here... for now we'd
@@ -92,7 +92,7 @@ extension Ghostty {
let diagsCount = ghostty_config_diagnostics_count(cfg)
if diagsCount > 0 {
logger.warning("config error: \(diagsCount) configuration errors on reload")
var diags: [String] = [];
var diags: [String] = []
for i in 0..<diagsCount {
let diag = ghostty_config_get_diagnostic(cfg, UInt32(i))
let message = String(cString: diag.message)
@@ -144,7 +144,7 @@ extension Ghostty {
var initialWindow: Bool {
guard let config = self.config else { return true }
var v = true;
var v = true
let key = "initial-window"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -152,7 +152,7 @@ extension Ghostty {
var shouldQuitAfterLastWindowClosed: Bool {
guard let config = self.config else { return true }
var v = false;
var v = false
let key = "quit-after-last-window-closed"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -345,7 +345,7 @@ extension Ghostty {
var macosWindowShadow: Bool {
guard let config = self.config else { return false }
var v = false;
var v = false
let key = "macos-window-shadow"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -418,14 +418,14 @@ extension Ghostty {
var focusFollowsMouse: Bool {
guard let config = self.config else { return false }
var v = false;
var v = false
let key = "focus-follows-mouse"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
}
var backgroundColor: Color {
var color: ghostty_config_color_s = .init();
var color: ghostty_config_color_s = .init()
let bg_key = "background"
if !ghostty_config_get(config, &color, bg_key, UInt(bg_key.lengthOfBytes(using: .utf8))) {
#if os(macOS)
@@ -449,7 +449,7 @@ extension Ghostty {
var v: Double = 1
let key = "background-opacity"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v;
return v
}
var backgroundBlur: BackgroundBlur {
@@ -471,11 +471,11 @@ extension Ghostty {
var unfocusedSplitFill: Color {
guard let config = self.config else { return .white }
var color: ghostty_config_color_s = .init();
var color: ghostty_config_color_s = .init()
let key = "unfocused-split-fill"
if !ghostty_config_get(config, &color, key, UInt(key.lengthOfBytes(using: .utf8))) {
let bg_key = "background"
_ = ghostty_config_get(config, &color, bg_key, UInt(bg_key.lengthOfBytes(using: .utf8)));
_ = ghostty_config_get(config, &color, bg_key, UInt(bg_key.lengthOfBytes(using: .utf8)))
}
return .init(
@@ -492,7 +492,7 @@ extension Ghostty {
guard let config = self.config else { return Color(newColor) }
var color: ghostty_config_color_s = .init();
var color: ghostty_config_color_s = .init()
let key = "split-divider-color"
if !ghostty_config_get(config, &color, key, UInt(key.lengthOfBytes(using: .utf8))) {
return Color(newColor)
@@ -587,7 +587,7 @@ extension Ghostty {
var v: UInt = 0
let key = "resize-overlay-duration"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v;
return v
}
var undoTimeout: Duration {
@@ -621,7 +621,7 @@ extension Ghostty {
var autoSecureInput: Bool {
guard let config = self.config else { return true }
var v = false;
var v = false
let key = "macos-auto-secure-input"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -629,7 +629,7 @@ extension Ghostty {
var secureInputIndication: Bool {
guard let config = self.config else { return true }
var v = false;
var v = false
let key = "macos-secure-input-indication"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -637,7 +637,7 @@ extension Ghostty {
var maximize: Bool {
guard let config = self.config else { return true }
var v = false;
var v = false
let key = "maximize"
_ = ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8)))
return v
@@ -802,29 +802,29 @@ extension Ghostty.Config {
func top() -> 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
}
}
}

View File

@@ -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) }

View File

@@ -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
}
}
}

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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)

View File

@@ -81,7 +81,7 @@ extension Ghostty {
// TODO
return
}
self.surface = surface;
self.surface = surface
}
required init?(coder: NSCoder) {