Repository: nushell/nushell (language: rust)

Issue:
tab completion on paths beginning with tilda produces broken results on paths with unusual characters
### Describe the bug

If you have a file with unusual characters (such as brackets, pipes), Nushell will erroneously wrap the path (beginning with tilda) with `'`. Consequentially, the tilda is not expanded, and the path it gives you is invalid.

### How to reproduce

1. Run nushell 0.98.0 with disabled config:
(If on NixOS: `nix run github:Nixos/nixpkgs#nushellFull -- --no-config-file --env-config /dev/zero`)

2. 

```nu
cd ~
mkdir 'test/a long complicated file name | [ ] wow'
```

3.

Type `ls ~/test/` then hit tab, and select the long complicated file name.

### Expected behavior

Like in Fish, Nushell should be able to properly escape or quote wrap the file name and give you a working path.

### Configuration


| key                | value                                                             |
| ------------------ | ----------------------------------------------------------------- |
| version            | 0.98.0                                                            |
| major              | 0                                                                 |
| minor              | 98                                                                |
| patch              | 0                                                                 |
| branch             |                                                                   |
| commit_hash        |                                                                   |
| build_os           | linux-x86_64                                                      |
| build_target       | x86_64-unknown-linux-gnu                                          |
| rust_version       | rustc 1.80.1 (3f5fd8dd4 2024-08-06) (built from a source tarball) |
| cargo_version      | cargo 1.80.0 (376290515 2024-07-16)                               |
| build_time         | 1980-01-01 00:00:00 +00:00                                        |
| build_rust_channel | release                                                           |
| allocator          | mimalloc                                                          |
| features           | default, sqlite, trash                                            |
| installed_plugins  |                                                                   |


Discussion / hints:
Just updated to v0.100.0, and can confirm this issue is still present.

Fix patch:
diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs
index e45ff9cf978ad..0a060666b878a 100644
--- a/crates/nu-cli/src/completions/completion_common.rs
+++ b/crates/nu-cli/src/completions/completion_common.rs
@@ -284,6 +284,8 @@ pub fn complete_item(
 pub fn escape_path(path: String, dir: bool) -> String {
     // make glob pattern have the highest priority.
     if nu_glob::is_glob(path.as_str()) {
+        let pathbuf = nu_path::expand_tilde(path);
+        let path = pathbuf.to_string_lossy();
         return if path.contains('\'') {
             // decide to use double quote, also need to escape `"` in path
             // or else users can't do anything with completed path either.


Test patch: