Commit graph

20019 commits

Author SHA1 Message Date
kerty
be95b176bc Fix incorrect first line checks in rendering
The right prompt was rendered even if scrolled.
The command line wasn't rendering on the first line, starting from 0 to the left prompt length. Steps to reproduce:
fish -C 'bind ctrl-g \'commandline $(printf %0"$(math $COLUMNS)"d0) $(seq $(math $LINES - 1))\''
# use ctrl-g
# observe that only one '0' is rendered
2025-01-31 13:37:27 +01:00
kerty
e2c9969840 Fix deletion of prompt in last 2 columns when first line soft wrapped
When drawing a soft wrapped line, the last 2 characters of the previous line are redrawn. If these 2 characters are occupied by the prompt, they are replaced with ' '.
Steps to reproduce:
fish -C 'function fish_prompt; printf %0"$(math $COLUMNS)"d 0; end'
# type anything
# observe that the last two characters of the prompt have been deleted
2025-01-31 13:37:27 +01:00
kerty
9915a07741 Convert Screen::write_char() to usize 2025-01-31 13:37:27 +01:00
kerty
7acc2b7223 Fix pager occupying empty soft wrapped lines
We need to add a line to the desired screen if the previous line was full or non-existent to prevent the pager from being drawn on empty soft wrapped or new lines.
Steps to reproduce:
fish -C '
    function fish_prompt; printf \>; end
    bind ctrl-g \'commandline  "ls $(printf %0"$(math $COLUMNS - 5)"d 0) "\''
# use ctrl-g and tab
# observe that the pager starts on the line with the cursor
2025-01-31 13:37:27 +01:00
kerty
5ecf5aef8a Fix regression causing variable completions to not have description
Regressed in 17bd7d0 (Switch completion_request_options_t from a list of flags to a struct, 2022-06-07).
2025-01-31 13:37:27 +01:00
kerty
1339da330e Fix crash when clicking on empty lines
This fixes a crash that occurred in Kitty when clicking on lines without characters, such as soft wrapped lines or first line without a prompt.
2025-01-31 13:37:27 +01:00
kerty
6bb19cf1f4 Fix not emitting osc_133_prompt_start without prompt
If the left prompt is defined to be empty, osc_133_prompt_start would not be emitted at all.
2025-01-31 13:37:27 +01:00
kerty
d667ec5061 Remove space for prompt if it occupies full line
If the prompt occupies the full width of the first line, each new line will soft wrap, leaving empty lines between. This change removes the indentation that matches the start of the line to the end of the prompt if the prompt width equals the terminal width.

Steps to reproduce:
fish -C 'function fish_prompt; printf %0"$COLUMNS"d 0; end'
# type "begin" and Enter
# observe that there was a spurious empty line
2025-01-31 13:37:27 +01:00
Fabian Boehm
e63fea1127 reader: only flash entire commandline if token is empty
So `git add dsfiojdsoif<TAB>` flashes the token, `git add <TAB>`
flashes the entire commandline because there is no token to flash
2025-01-30 17:13:09 +01:00
Fabian Boehm
4ae3c487a6 reader: flash entire commandline if there's no completion
This is often the case if the token is empty, e.g `git add <TAB>`
outside of a git repo.
2025-01-30 16:24:35 +01:00
Fabian Boehm
6c4d658c15 pager: fix selected color regression
To check:

```fish
fish_config theme choose None
set -g fish_pager_color_selected_completion blue
```

Now the selected color will only apply to the parentheses

Missed in 43e2d7b48c (Port pager.cpp)
2025-01-30 16:22:07 +01:00
Fabian Boehm
ba193665e2 completions: Add missing options for our builtins 2025-01-29 20:38:41 +01:00
Fabian Boehm
66f1aba0f2 completions/commandline: Add missing options 2025-01-29 20:17:46 +01:00
Fabian Boehm
ef4fad763f Remove fish.desktop harder 2025-01-29 17:21:14 +01:00
Justin Zobel
a42c5b4025 Remove fish.desktop file as it was only needed for AppImages which were decided against. 2025-01-29 17:19:39 +01:00
David Adam
be48d73599 docs/fish: minor style/proofing edits 2025-01-29 20:28:00 +08:00
David Adam
1cf71656ef docs/language: update target release for feature flags from 3.8 to 4.0
see also 24abbb6de7
2025-01-29 20:27:14 +08:00
Johannes Altmanninger
acf9ba4195 Fix regression causing missing automatic history saving after adding ephemeral items
Commit f36f757fa6 (Never rewrite history file when adding ephemeral
items, 2024-10-06) has a glaring bug: when adding to history ephemeral
items that has potential paths, we fail to re-enable automatic saving,
which effectively disables automatic saving for the entire session.

Only a call to history::save_all() at exit saves us from losing data.
But until exit, other fish will see our history (unless we run history
save/merge or similar).

Fix the imbalanced enable/disable and restructure the code a bit.
Also, extend the change from f36f757fa6 (never vacuum on ephemeral
items) to private mode.
2025-01-29 10:16:19 +01:00
Ilya Grigoriev
064d867873 language.rst: make description of features more consistent (minor)
The version where a feature became the default is now described inline,
to make it a single source of truth. I could have fixed the other
section where this was described, but this seemed easier.

I also removed a few details that seem no longer relevant.
2025-01-28 21:23:45 -08:00
David Adam
2184aaf9b4 completions/acpi: correct the -c option as cooling
Closes #11068.
2025-01-28 21:47:05 +08:00
Ilya Grigoriev
f241187c4a completions/tmux: some windows and panes boolean flag completions
This documents some non-argument options for the window and panes
commands. The choice of what to document is somewhat arbitrary,
this commit is biased towards options that I find confusing or
misleading without documentation (is `-a` "all" or "after"?)
and the command that seem more useful to me.

I also didn't cover the options that would be covered by
#10855 (though this PR can be used independently). I'm not
sure how much difference this made, it might not matter at
all.
2025-01-28 21:38:34 +08:00
Ilya Grigoriev
77406ddd11 completions/tmux: complete commands inside tmux lscm
Make `tmux lscm <tab>` work.
2025-01-28 21:37:16 +08:00
Ilya Grigoriev
183e20cc3a completions/tmux: complete all flags when tmux lscm is available
These dynamic completions are exhaustive, but not as well-documented or
as ergonomic as the manual completions. So, any manual completions
should override them.
2025-01-28 21:37:16 +08:00
Ilya Grigoriev
27e5ed7456 completions/tmux: complete all subcommands when tmux lscm works
For example, `tmux shell<tab>` now completes to `if-shell` and
`run-shell`, though no additional information is provided.
2025-01-28 21:37:16 +08:00
Johannes Altmanninger
d2b2c5286a Fix regression decoding function keys
Commit 109ef88831 (Add menu and printscreen keys, 2025-01-01)
accidentally broke an assumption by inverting f1..f12.  Fix that.

Fixes #11098
2025-01-27 21:49:29 +01:00
Fabian Boehm
9116c61736 completions/nmcli: Complete at runtime
This used to get all the interfaces and ssids when the completions
were loaded. That's obviously wrong, given that ssids especially can, you know, change
2025-01-27 20:46:38 +01:00
Fabian Boehm
4370fb755d completions/git: Handle untracked files separately
This uses `git ls-files`, which has a simpler format (just the
filenames on separate lines), in order to print the untracked files.

This allows us to skip them in the `git status` call, which reduces
the output a lot and removes two `string match`.

In a repository with over half a million files (my home directory, if
I made it one), this improves time by a third (12s to 8s).

In a smaller repo (fish-shell) it's barely measurable.
2025-01-27 18:24:08 +01:00
kerty
514f4b9e23 Rename some methods of ReaderHistorySearch to improve clarity 2025-01-27 18:19:04 +01:00
Johannes Altmanninger
b73c8abb79 Fix regression causing crash when history token search hits end
This is consistent with what we do for highlighting history search,
see d7354880e3 (Fix regression causing crash in token history search,
2025-01-27).  In future, we should try to find a better fix (and a
better test).

Fixes the other problem described in #11096
2025-01-27 18:13:07 +01:00
Fabian Boehm
5c81e18b2e completions/git: Handle gigantic repos better
Determine if untracked files are off via `__fish_git`, so we get the
repo used on the commandline etc,

and if it isn't, at least don't error out. Yes, this *can* print a
hundred megabytes of filenames.
2025-01-27 17:52:32 +01:00
Fabian Boehm
bba15c6d14 completions/csvlens: Fix missing option 2025-01-27 17:51:35 +01:00
Johannes Altmanninger
d7354880e3 Fix regression causing crash in token history search
I'm not yet sure how to reproduce 4dfcd4cb4e (reader: Check bounds
for color, 2022-08-26).  Commit 55fd43d86c (Port reader, 2023-12-22)
accidentally changed historical behavior, fix that.

Fixes #11096
2025-01-27 06:32:15 +01:00
Johannes Altmanninger
fff421ad9c Work around mc and dvtm not responding to Primary DA
The two terminals Midnight Commander and dvtm are special in that
they filter requests (or perhaps responses) like

	printf "\x1b[0c"

and don't implement the response themselves -- so we never get
one. Let's work around that until we can fix it.

Disable the kitty protocol in mc for now (to keep the code simple),
though we could certainly re-enable it.

Fixes 64859fc242 (Blocking wait for responses to startup queries, 2025-01-25).
2025-01-27 06:32:15 +01:00
ccoVeille
90e916e164 Fix typo in tests 2025-01-26 20:30:48 -08:00
ccoVeille
0047abbe7a Fix typo in code 2025-01-26 20:30:48 -08:00
ccoVeille
b6a1bedab9 Fix typos in comments 2025-01-26 20:30:48 -08:00
Mahmoud Al-Qudsi
88c8992cc3 Add inline attribute 2025-01-26 17:21:49 -06:00
Fabian Boehm
2b2f824b94 completions/git: Handle huge repositories for "add" better
`git add` may have to go through literal megabytes of file information
because of tons of untracked files.

So, if the repository is set to not show untracked files (because it's
too slow for the prompt), let's fall back on regular file completions.

(the alternative is to go back to `while read`, but that takes much
longer in repositories of a sensible size)

Fixes #11095
2025-01-26 21:41:36 +01:00
Johannes Altmanninger
c651a79cb6 Fix regression causing builtin commandline to report wrong relative cursor
Regressed in 55fd43d86c (Port reader, 2023-12-22).

Fixes #11085
2025-01-26 15:51:05 +01:00
Johannes Altmanninger
4c28a7771e Sanitize some inputs in CSI parser
This was copied from C++ code but we have overflow checks, which
forces us to actually handle errors.

While at it, add some basic error logging.

Fixes #11092
2025-01-26 15:39:21 +01:00
Johannes Altmanninger
2d234bb676 Only request keyboard protocols once we know if kitty kbd is supported
Today we might
1. enable modifyOtherKeys
2. get a reply indicating the kitty keyboard protocol is supported
3. because of 2, we never turn off modifyOtherKeys again

Let's get rid of this weird issue by enabling either modifyOtherKeys
or the kitty enhancements only after we know whether the kitty protocol
is supported.

This means we need to call terminal_protocols_enable_ifn() before every
call to readch() until the querying is done.  Fortunately, this is
already in place in read_normal_chars(); there are other places that
call readch() but none of those is executed until querying has completed.
2025-01-26 15:39:21 +01:00
Johannes Altmanninger
64859fc242 Blocking wait for responses to startup queries
At startup we query for
- the cursor position (CSI 6 n)
- kitty keyboard protocol support (CSI ? u)
- terminfo capabilities via XTGETTCAP

Since we don't wait for responses, those can leak into child processes.
Some child processes like fzf cannot decode DCS replies.  Plug the
leak by ending each round of querying by asking for the Primary Device
Attribute, and resume input processing only after a response has been
received, (or ctrl-c as an escape hatch).

This is a nice simplification. Tested with the lowest common
denominator (putty, Terminal.app and st).

Fixes #11079
2025-01-26 14:22:52 +01:00
Johannes Altmanninger
06b49b9721 Update pexpect helper output sanitization 2025-01-26 14:19:40 +01:00
Johannes Altmanninger
630a06cf8f Work around st terminal resetting cursor on CSI ? u
The st terminal wrongly parses CSI ? u as DECRC. A fix has been
proposed upstream.  Let's also work around it I guess (not to mention
that querying in the first place is also sort of a workaround).
2025-01-26 14:19:40 +01:00
Johannes Altmanninger
95d61ea0fb Split /etc/{,man}path by colons too
I don't know how /etc/manpath ends up containing lines like
"path1:path2".  But path_helper splits them so we should do too.

4ea11424b8/path_helper/path_helper.c (L149)

Fixes #10684
2025-01-26 14:19:40 +01:00
Johannes Altmanninger
6e2c5d4365 Add trailing slash (not space) to variable name completions that produce valid paths
Closes #5798
2025-01-26 14:19:40 +01:00
Fabian Boehm
545a23734e Remove some ffi wrappers 2025-01-25 20:03:13 +01:00
Mahmoud Al-Qudsi
d69a9296a6 completions/llm: Complete model alias target 2025-01-25 12:50:03 -06:00
kerty
3fdd2d3fc2 Small refactor of HighlightSpec 2025-01-23 17:09:29 +01:00
kerty
db546da3ca Made undo/redo not update autosuggestion if failed 2025-01-23 17:09:29 +01:00