From 6990c1572acc82a1371279562cafea575bae9e36 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 14 Oct 2023 21:06:34 -0700 Subject: [PATCH] macos: insertText should not include null char --- macos/Sources/Ghostty/SurfaceView.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 8ee2066e5..8752ebe08 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -841,10 +841,13 @@ extension Ghostty { default: return } - + let len = chars.utf8CString.count + if (len == 0) { return } + chars.withCString { ptr in - ghostty_surface_text(surface, ptr, UInt(len)) + // len includes the null terminator so we do len - 1 + ghostty_surface_text(surface, ptr, UInt(len - 1)) } }