mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-24 22:00:16 +00:00
When AppKit delivers a single C0 control character during marked-text composition, Ghostty should treat it as input consumed by the composing state instead of forwarding it to the terminal. This prevents control-key IME actions, such as Japanese input shortcuts like ctrl+h/j/m/n, from leaking into the terminal while composition is still active. Printable text and non-composing control input continue through the normal key path. AI usage: OpenAI Codex helped investigate, implement, test, and refine this change. I reviewed and tested the resulting code.
45 lines
1.1 KiB
Swift
45 lines
1.1 KiB
Swift
@testable import Ghostty
|
|
import Testing
|
|
|
|
struct SurfaceViewAppKitTests {
|
|
@Test(arguments: [
|
|
("\u{0008}", true),
|
|
("\u{001F}", true),
|
|
("\u{007F}", false),
|
|
(" ", false),
|
|
("h", false),
|
|
("", false),
|
|
("\u{0009}x", false),
|
|
("\u{0009}\u{0009}", false),
|
|
])
|
|
func suppressesOnlySingleC0ControlTextWhileComposing(
|
|
text: String,
|
|
expected: Bool
|
|
) {
|
|
#expect(
|
|
Ghostty.SurfaceView.shouldSuppressComposingControlInput(
|
|
text,
|
|
composing: true
|
|
) == expected
|
|
)
|
|
}
|
|
|
|
@Test func doesNotSuppressControlTextWhenNotComposing() {
|
|
#expect(
|
|
Ghostty.SurfaceView.shouldSuppressComposingControlInput(
|
|
"\u{0008}",
|
|
composing: false
|
|
) == false
|
|
)
|
|
}
|
|
|
|
@Test func doesNotSuppressMissingText() {
|
|
#expect(
|
|
Ghostty.SurfaceView.shouldSuppressComposingControlInput(
|
|
nil,
|
|
composing: true
|
|
) == false
|
|
)
|
|
}
|
|
}
|