Conversation
WalkthroughSS3 escape-sequence handling was extended to accumulate CSI-like parameters, parse semicolon-delimited modifier values, and emit SS3 keys with calculated modifiers. Tests were expanded with a comprehensive TestSpecialKeys suite covering CSI/SS3 sequences and modifier combinations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
input.go(2 hunks)input_test.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
input.go (1)
key.go (2)
NewEventKey(249-308)ModNone(325-325)
input_test.go (2)
key.go (30)
KeyEscape(517-517)ModNone(325-325)KeyRune(339-339)ModCtrl(321-321)KeyCtrlA(443-443)Key(332-332)ModMask(312-312)KeyTab(515-515)KeyEnter(518-518)KeyBackspace(514-514)KeyEnd(352-352)KeyHome(351-351)KeyInsert(353-353)KeyF1(362-362)KeyF2(363-363)KeyF4(365-365)KeyBacktab(361-361)ModShift(320-320)KeyF5(366-366)KeyF6(367-367)KeyF7(368-368)KeyF8(369-369)KeyF9(370-370)KeyF10(371-371)KeyF11(372-372)KeyF12(373-373)KeyF3(364-364)ModMeta(323-323)NewEventKey(249-308)EventKey(45-50)event.go (1)
Event(23-26)
🔇 Additional comments (5)
input_test.go (3)
89-93: LGTM!Comment formatting improvements enhance readability.
276-279: LGTM!Comment formatting improvements.
552-561: Good test coverage for SS3 modifier formats.The tests cover the key SS3 modifier formats: standard
1;mod, short formmod, and empty-prefix;mod. This aligns well with the implementation ininput.go.input.go (2)
449-452: LGTM!Resetting
csiParamswhen entering SS3 state ensures clean parameter accumulation for SS3 sequences with modifiers.
506-527: Verify handling of unexpected SS3 parameter formats.The modifier parsing logic at lines 519-525 handles specific formats (
1;mod,;mod,mod), but if a sequence has an unexpected first parameter (e.g.,ESC O 2;5 P), no event is posted. This may be intentional to ignore non-conforming sequences, but could also silently drop valid user input from uncommon terminals.Consider whether a fallback to emit the key with
ModNonewould be safer:} else if parts := strings.Split(string(ip.csiParams), ";"); len(parts) >= 1 { // SS3 with modifier (old style). Note old terminfo would declare these as high // numbered function keys, but we encode as modified since that's how they are entered. if len(parts) >= 2 { if m, err := strconv.Atoi(parts[1]); err == nil && (parts[0] == "1" || parts[0] == "") { ip.post(NewEventKey(k, "", calcModifier(m))) + } else { + // Unrecognized format, emit key without modifiers + ip.post(NewEventKey(k, "", ModNone)) } } else if m, err := strconv.Atoi(parts[0]); err == nil { ip.post(NewEventKey(k, "", calcModifier(m))) + } else { + // Failed to parse modifier, emit key without modifiers + ip.post(NewEventKey(k, "", ModNone)) } }If the current behavior is intentional (ignoring non-conforming sequences), a brief comment would help clarify this design choice.
While here update for loops to modern go range loops.
57c7416 to
27832af
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
input_test.go (1)
515-587: Comprehensive CSI/SS3 special-key coverage; only minor nitsThe new
TestSpecialKeystable is a solid, centralized way to validate CSI and SS3 sequences and modifier handling, including the legacy SS3 modifier forms and mixed encodings.Two small, optional nits:
- The error message
"Timeout waiting for UTF-8 character event"is a bit misleading here since many cases are non-UTF8 control sequences; consider a more generic message like"special key event"if you touch this again.- If you ever need stricter regression checks, you might also assert
Str()for a few representative entries (e.g., ESC vs Tab/Enter) to catch accidental string changes.These are polish-only; the functional expectations (keys + modifiers) look consistent with the described behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
input.go(2 hunks)input_test.go(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- input.go
🧰 Additional context used
🧬 Code graph analysis (1)
input_test.go (2)
key.go (9)
ModNone(325-325)KeyRune(339-339)ModCtrl(321-321)KeyCtrlA(443-443)Key(332-332)ModMask(312-312)ModShift(320-320)NewEventKey(249-308)EventKey(45-50)event.go (1)
Event(23-26)
🔇 Additional comments (3)
input_test.go (3)
89-93: Control-key coverage for 0x1B–0x1F looks correctThe added cases for ESC and 0x1C–0x1F (mapping to
KeyEscapeandKeyRunewithModCtrl) align with the documentedNewEventKeybehavior and nicely complete the control-key table.
276-279: Sequential input expectations match null-byte semanticsThe updated expectations for the sequential inputs—especially treating
0x00asKeyRune+" "+ModCtrl—are consistent with the earlier null-byte tests and ensure queue ordering is exercised.
443-459:for range 10is valid Go syntax as of Go 1.22 and is perfectly acceptable in this codebase (which requires Go 1.24.0 per go.mod). No changes are needed.Likely an incorrect or invalid review comment.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.