Skip to content

Commit e0e0e35

Browse files
Merge pull request #1834 from lifrary/fix/replace-force-unwrapped-utf8-data-encoding
Replace force-unwrapped .data(using: .utf8)! with Data(string.utf8)
2 parents 01ffeb3 + 8ad794f commit e0e0e35

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/GhosttyTerminalView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ class GhosttyApp {
10401040
let line = "[\(timestamp)] \(message)\n"
10411041
if let handle = FileHandle(forWritingAtPath: initLogPath) {
10421042
handle.seekToEndOfFile()
1043-
handle.write(line.data(using: .utf8)!)
1043+
handle.write(Data(line.utf8))
10441044
handle.closeFile()
10451045
} else {
10461046
FileManager.default.createFile(atPath: initLogPath, contents: line.data(using: .utf8))
@@ -3127,7 +3127,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
31273127
let line = "[\(timestamp)] \(message)\n"
31283128
if let handle = FileHandle(forWritingAtPath: surfaceLogPath) {
31293129
handle.seekToEndOfFile()
3130-
handle.write(line.data(using: .utf8)!)
3130+
handle.write(Data(line.utf8))
31313131
handle.closeFile()
31323132
} else {
31333133
FileManager.default.createFile(atPath: surfaceLogPath, contents: line.data(using: .utf8))
@@ -3141,7 +3141,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
31413141
let line = "[\(timestamp)] \(message)\n"
31423142
if let handle = FileHandle(forWritingAtPath: sizeLogPath) {
31433143
handle.seekToEndOfFile()
3144-
handle.write(line.data(using: .utf8)!)
3144+
handle.write(Data(line.utf8))
31453145
handle.closeFile()
31463146
} else {
31473147
FileManager.default.createFile(atPath: sizeLogPath, contents: line.data(using: .utf8))

Sources/WorkspaceContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ extension WorkspaceContentView {
688688
let logPath = "/tmp/cmux-panel-debug.log"
689689
if let handle = FileHandle(forWritingAtPath: logPath) {
690690
handle.seekToEndOfFile()
691-
handle.write(line.data(using: .utf8)!)
691+
handle.write(Data(line.utf8))
692692
handle.closeFile()
693693
} else {
694694
FileManager.default.createFile(atPath: logPath, contents: line.data(using: .utf8))

0 commit comments

Comments
 (0)