Repository: alexpasmantier/television (language: rust)

Issue:
Extraneous space when triggering television with implicit directory change in Fish
**Description**
Some shells, like Fish, support [implicit directory changing](https://fishshell.com/docs/current/cmds/cd.html). Put simply, you can just type `./directory` instead of `cd ./directory` and the shell will know that you intended to navigate to the directory.

With that in mind, I have configured television like this:

```toml
[shell_integration.commands]

# dirs channel
"cd" = "dirs"
"ls" = "dirs"
"./" = "dirs" # makes television work with implicit cd
"rmdir" = "dirs"
```

The newer completions introduced [here](https://github.com/alexpasmantier/television/pull/200/files) now add a space if you try to use implicit cd. So, typing `./`, pressing Ctrl+T (or whatever your `tv` trigger is), and selecting your target results in a prompt that resembles something like this:

```sh
./ my/selected/dir
```

Unfortunately, this will result in an error:

```
fish: Unknown command. './' exists but is not an executable file.
 ./ my/selected/dir
 ^^
```

**Example**
https://github.com/alexpasmantier/television/pull/200/files#diff-729af7f6576851cfe4583acd70549b49fa918aa738fa7f0effed5e54fb996021R8

**Expected behavior**
`tv` should not add a space before your selected directory if you are using implicit directory changing.

**Actual behavior**
`tv` adds a space before your selected directory when using implicit directory changing.

**Environment**
 - OS: macOS + Linux
 - Rust version: `1.83.0`
 - Project version: `0.8.6`

**Additional context**
For now, I've just commented out the following line in my local completions:

```fish
# string match -q "* " -- "$current_prompt" || set current_prompt "$current_prompt "
```


Discussion / hints:

Fix patch:
diff --git a/crates/television-utils/shell/completion.fish b/crates/television-utils/shell/completion.fish
index 6e84ebe..f828c66 100644
--- a/crates/television-utils/shell/completion.fish
+++ b/crates/television-utils/shell/completion.fish
@@ -4,8 +4,8 @@ function tv_smart_autocomplete
     set -l output (tv --autocomplete-prompt "$current_prompt")
 
     if test -n "$output"
-        # add a space if the prompt does not end with one
-        string match -q "* " -- "$current_prompt" || set current_prompt "$current_prompt "
+        # add a space if the prompt does not end with one (unless the prompt is an implicit cd, e.g. '\.')
+        string match -r '.*( |./)$' -- "$current_prompt" || set current_prompt "$current_prompt "
         commandline -r "$current_prompt$output"
     end
 end


Test patch: