ZIm/crates/terminal/src
Finn Evers f6d4a73c34
terminal: Prevent [] from being sanitized into clickable file link (#20386)
This PR prevents `[]` from being sanitized into an empty string and thus
becoming a "valid", clickable file link in the integrated terminal.


Whenever you type `[]` into the terminal and hover over it while
pressing `cmd`, an empty popup appears and the cursor indicates that
this is a clickable element. Once you click on the brackets, the
worktree root is selected and focused within the file picker.

<img width="87" alt="grafik"
src="https://github.com/user-attachments/assets/01790323-88be-4373-a1ec-a345bcf2521e">


This is because in #2906 support was added for sanititzing file links
like `[/some/path/[slug].tsx]` to `/some/path/[slug].tsx`. In the case
`[]` where an empty string is returned from the sanitation, the string
is considered a valid file path and thus `[]` becomes a valid and
clickable navigation target.

Given that this an edge-case just for this specific one set of brackets
and otherwise no empty strings are matched from the regexes `URL_REGEX`
and `WORD_REGEX`, it seemed that this was the best place to fix this
bug.

Release Notes:

- `[]` is no longer considered a clickable link in the terminal
2024-11-08 02:41:30 +02:00
..
mappings Fix sending alt-enter in terminal (#18363) 2024-09-25 18:01:33 -04:00
pty_info.rs Update Rust crate sysinfo to 0.31.0 (#17733) 2024-09-17 21:50:37 +02:00
terminal.rs terminal: Prevent [] from being sanitized into clickable file link (#20386) 2024-11-08 02:41:30 +02:00
terminal_settings.rs Make terminal.option_as_meta=false in default settings (#19364) 2024-10-17 10:31:35 -04:00