Hi everyone,
I'm working on the Shell challenge in Elixir and I'm stuck on Stage QP2 (Autocompletion - Builtin completion).
## Problem
When the test presses TAB, I receive spaces instead of the TAB character (byte 9):
- **Expected**: `"$ echo "`
- **Received**: `"$ ech "` (with spaces)
## What I've Tried
1. **ex_readline library** - Has a bug where tab completion only works with "/" prefix
2. **Custom implementation** with `IO.getn` - Detects TAB (byte 9) locally but not in test environment
3. **stty raw mode** - Works in TTY but CodeCrafters test environment is non-TTY
## My Implementation
```elixir
defp read_loop(buffer, completion_fn, prompt) do
input = IO.getn("", 1)
case input do
<<9>> when completion_fn != nil -> # TAB
new_buffer = handle_tab_completion(buffer, completion_fn, prompt)
read_loop(new_buffer, completion_fn, prompt)
# ... other cases
end
end
Questions
- Has anyone successfully completed this stage in Elixir?
- Is there a specific library or approach recommended for Elixir?
- How does the test environment simulate TAB key presses?
Repository
All my attempts are documented here: GitHub - Illuminaxx/codecrafters-shell-elixir See AUTOCOMPLETE_NOTES.md for detailed investigation
The Elixir ecosystem doesn’t have a mature readline library like Python’s readline or Rust’s rustyline, which makes this stage particularly challenging.
Any help would be greatly appreciated! ![]()