in the screenshot, on each line i press tab, it looks correct but the test results fail?:
[compile] Moved ./.codecrafters/run.sh β ./your_program.sh
[compile] Compilation successful.
[tester::#WH6] Running tests for Stage #WH6 (Autocompletion - Multiple completions)
[tester::#WH6] [setup] export PATH=/tmp/ant:$PATH
[tester::#WH6] [setup] export PATH=/tmp/bee:$PATH
[tester::#WH6] [setup] export PATH=/tmp/fox:$PATH
[tester::#WH6] [setup] Available executables:
[tester::#WH6] [setup] - xyz_dog
[tester::#WH6] [setup] - xyz_fox
[tester::#WH6] [setup] - xyz_cow
[tester::#WH6] Running ./your_program.sh
[tester::#WH6] β Received prompt ($ )
[tester::#WH6] Typed "xyz_"
[your-program] $ xyz_
[tester::#WH6] β Prompt line matches "$ xyz_"
[tester::#WH6] Pressed "<TAB>" (expecting bell to ring)
[tester::#WH6] β Received bell
[tester::#WH6] Pressed "<TAB>" (expecting autocomplete to "xyz_cow xyz_dog xyz_fox")
[tester::#WH6] Didn't find expected line.
[tester::#WH6] Expected: "xyz_cow xyz_dog xyz_fox"
[tester::#WH6] Received: "" (no line received)
[tester::#WH6] Assertion failed.
[tester::#WH6] Test failed
snippet:
TAB_COUNT = 0
LAST_BUFFER = ""
CACHED_MATCHES = []
def completer(text: str, state: int):
global TAB_COUNT, LAST_BUFFER, CACHED_MATCHES
if state != 0: return None
buffer = readline.get_line_buffer()
if readline.get_begidx() != 0: return None
if buffer != LAST_BUFFER:
TAB_COUNT = 0
LAST_BUFFER = buffer
matches = []
for cmd in commands.BUILTINS.keys():
if cmd.startswith(text):
matches.append(cmd)
for _, files in commands.get_path_files().items():
for file in files:
if file.startswith(text):
matches.append(file)
matches = sorted(set(matches))
CACHED_MATCHES = matches
if not matches:
return None
if len(matches) == 1:
TAB_COUNT = 0
return matches[0] + " "
TAB_COUNT += 1
if TAB_COUNT == 1:
sys.stdout.write("\x07")
sys.stdout.flush()
return None
if TAB_COUNT == 2:
sys.stdout.write("\n")
sys.stdout.write(" ".join(matches) + "\n")
sys.stdout.write("$ " + buffer)
sys.stdout.flush()
TAB_COUNT = 0
return None
return None
