summaryrefslogtreecommitdiff
path: root/internal/repl/completer_adapter_test.go
AgeCommit message (Collapse)Author
2026-05-25fix: return readline suffixes instead of full matchesPaul Buetow
Per the readline AutoCompleter docs, Do() should return suffixes (the characters AFTER the common prefix), not full matches. The length parameter indicates how many characters are shared. This fixes the bug where readline appended the full match to the typed input (e.g. 'he' + 'help' = 'hehelp') because commonLen was 0 and readline had no idea what to replace. Now 'he<TAB>' returns suffix 'lp' with commonLen=2, so readline correctly replaces 'he' with 'help'.
2026-05-25fix: don't offer exact-match completions to prevent readline duplicationPaul Buetow
When the typed word already exactly matches a command (e.g. 'help'), return no completions. Readline would append the match, producing 'helphelp'. Partial matches still work normally (e.g. 'he' → 'help').
2026-05-23test: add unit tests for REPL subsystemsPaul Buetow
Add dedicated unit tests for four REPL components that lacked test coverage: - SignalHandler (signal_test.go): 5 tests covering constructor, Stop() without Start, callback execution, goroutine semantics, and single-shot signal handling behavior - TTYChecker (tty_test.go): 5 tests covering EnsureTTY error in non-TTY context, error message content, IsTTY return value, IsTTY/EnsureTTY consistency, and idempotent behavior - HistoryManager (history_test.go): 11 tests covering constructor, Path() with default and custom baseDir, Save/Load roundtrip, maxEntries truncation, non-existent file, empty file/slice, special characters, and file overwrite behavior. Added WithBaseDir() method to enable testing with temp directories. - AutoCompleteAdapter (completer_adapter_test.go): 5 tests covering Do() with empty/whitespace input, exact/partial/no matches, case-insensitive matching, multi-word completion, cursor position, common prefix calculation, and command order preservation