Commit graph

19313 commits

Author SHA1 Message Date
Johannes Altmanninger
263f1b35de Reapply "Clear to eol before outputting line in multi-line prompt"
In case a terminal resize[1] causes us
to repaint a multi-line prompt that changes width like

    function fish_prompt
        for i in 1 2 3
            random choice 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbb'
        end
    end

we add a clr_eol after each line[2] , to make sure
that a "b" line does not have leftover "a" letters
(80aaae5b7 (Clear to end of each line in left prompt, 2020-10-25)).

Unfortunately, if a prompt line takes up all the columns, clr_eol will
wrongly clear the last column. Reproduce with

    function fish_prompt
        string repeat $COLUMNS -
        echo "$PWD> "
    end

and observe that the last "-" is missing.

Previous (reverted) attempt d3ceba107 (Clear to eol before outputting line
in multi-line prompt, 2021-05-17) found the right fix but had an off-by-one
error which reintroduced the leftover "a" letters in the "random choice"
prompt above.

Given prompt string "aa\nbb\ncc", it wrongly printed

    clr_eol "aa" clr_eol "\nbb" "\ncc"

Observe that the first line is cleared twice, while the second line is
never cleared. Fix that.

[1]: or an async "commandline -f repaint" triggered by a uvar change /
     async prompt update
[2]: except after the last line where we probably already emit clr_eol
     elsewhere..

Alternative fix: emit both clr_eol and clr_bol *before* drawing the current
line. However, if fish and the terminal disagree on character width, that
approach might erase too much.

Closes #8164
2024-09-28 10:39:54 +02:00
Fabian Boehm
48a6550688 Remove obsolete workaround for strftime on BSD
This was added in libc 0.2.152, see aff5e66e54
2024-09-24 21:38:15 +02:00
Fabian Boehm
798150ac39 Update widecharwidth for Unicode 16
Commit 533e50efb0b9b122a08f2273337dbf6b44b03cc7 upstream.
2024-09-24 17:00:13 +02:00
Peter Ammon
4e8d6b1760
Improve the README of the printf crate 2024-09-23 11:16:42 -07:00
Johannes Altmanninger
308ed62d83 fish_key_reader: stop emitting \n for ctrl-j
I guess it's nice to know that these two are the same but that info is not
needed here, it just adds confusion. The user must have pressed ctrl-j if
we get here, so echo that back.

See the parent commit.
2024-09-23 20:08:46 +02:00
Johannes Altmanninger
4336f9df7f fish_key_reader: stop emitting \b for ctrl-h
This is just too confusing; \b sounds like it would map backspace but it's
actually just ctrl-h.  Backspace is a different key ("bind backspace"),
so let's move away from \b.

Reproduce by typing ctrl-h in fish_key_reader, or, for even more confusion,
use a terminal like tmux and type ctrl-backspace which also sends ctrl-h.

I've thought about changing \b (and its aliases like \ch and \x08) to mean
backspace but that seems like unnecessary breakage, since they all already
mean ctrl-h, and can usually be mapped independent of backspace.

See the discussion in #10738
2024-09-23 20:00:35 +02:00
Johannes Altmanninger
2e9de57fd7 Document ctrl-backspace and bind ctrl-delete as well
This has a slightly different behavior than what the CUA user expects:
it fails to eat up trailing spaces.  We should probably fix this.
2024-09-23 14:52:50 +02:00
Johannes Altmanninger
904649c5c5 Bind ctrl-backspace to backward-kill-word
Closes #10741
2024-09-23 14:32:43 +02:00
Peter Ammon
e3993a3d96
Update code and Cargo.toml for recent pcre2-utf32 changes 2024-09-22 17:05:14 -07:00
Peter Ammon
617b61cd3a
Clean up fd_monitor getter
No need for UnsafeCell
2024-09-22 14:02:55 -07:00
Peter Ammon
fb700ca50d
Clean up a few more comments 2024-09-22 13:11:40 -07:00
Peter Ammon
f733553ac8
Clean up some stale comments 2024-09-22 13:09:11 -07:00
Peter Ammon
520a3b5a12
Add a repository field to fish_printf's manifest 2024-09-21 18:43:46 -07:00
Peter Ammon
974ad882fa
Clean up fish-printf in preparation for publishing
Make fish-printf no longer depend on the widestring crate, as other clients
won't use it; instead this is an optional feature.

Make format strings a generic type, so that both narrow and wide strings can
serve. This removes a lot of the complexity around converting from narrow to
wide.

Add a README.md to this crate.
2024-09-21 17:52:11 -07:00
Fabian Boehm
cdcf460edf math: Nicer error for non-ascii-lowercase identifiers
This gave a weird error when you did e.g. `math Foo / 6`:

"Missing Operator" and only the "F" marked.

Adding an operator here anywhere won't help, so calling this an
"Unknown function" is closer to the truth. We also get nicer markings
because we know the extent of the identifier.
2024-09-18 22:27:00 +02:00
Fabian Boehm
fc7be1c2a3 Minor doc fixes 2024-09-18 22:11:14 +02:00
EmilyGraceSeville7cf
0277fe3ca9 feat(completion): add test-spice support 2024-09-17 19:44:09 +02:00
EmilyGraceSeville7cf
98de7ea14a feat(completion): add validate-spice support 2024-09-17 19:44:09 +02:00
EmilyGraceSeville7cf
63e7608be4 feat(completion): add cascadia completion 2024-09-17 19:43:31 +02:00
mattmc3
9eee1b4499 fish_indent: Cleanup all *.fish files not in tests 2024-09-17 19:11:42 +02:00
Johannes Altmanninger
add0a9dfcd fish_indent: clean up file writing logic
Fix 7308dbc7a (fish_indent: Prevent overwriting file with identical content,
2024-07-21) in a different way by passing O_TRUNC again.
If we don't want regressions we could use code review.
2024-09-16 21:27:11 +02:00
Fabian Boehm
e27f4a3744 fish_indent: Truncate file to the size of the text
This can happen in case the formatted script is shorter, e.g. because
we ditched superfluous quotes.

Fixes #10724
2024-09-16 21:08:53 +02:00
Fabian Boehm
9fafae7a8a docs/complete: Explain -r a bit better 2024-09-15 09:44:09 +02:00
Fabian Boehm
8092af9c45 docs/prompt: Add funcsave/funced 2024-09-15 09:39:13 +02:00
Fabian Boehm
f9635b1a04 docs/argparse: Explain dashes in flag names 2024-09-15 09:39:09 +02:00
Johannes Altmanninger
1e2368f609 Fix off-by-one-error parsing \e\e prefixed sequences
Closes #10721
2024-09-14 22:56:37 +02:00
Rebecca Turner
a6c8cd6e85 Fix man completions on macOS with symlinked manpath
When `manpath` prints a symlink to a directory, `/usr/libexec/makewhatis`
ignores the entire directory:

```
$ /usr/libexec/makewhatis -o /tmp/whatis \
    (/usr/bin/manpath | string split :)
makewhatis: /Users/wiggles/.nix-profile/share/man: Not a directory
```

This means that the built-in `man` completions will not index any commands in
these directories.

If we pass the directories to `readlink -f` first, `makewhatis` correctly
indexes the `man` pages.

```
$ /usr/libexec/makewhatis -o /tmp/whatis \
    (/usr/bin/manpath | string split : | xargs readlink -f)
```
2024-09-14 13:38:33 -07:00
Kerim
bc55945072 improved vi keybind 2024-09-14 13:33:21 -07:00
Peter Ammon
8f3a034264
History to store old item offsets in Vec and not VecDeque
We used deque in C++ because this vector may be large, and so it avoids
repeated re-allocations. But VecDeque is different in Rust - it's contiguous -
so there's no benefit. Just use Vec.
2024-09-14 13:26:34 -07:00
Peter Ammon
7ac62bbca4
Remove a redundant "unsafe" specifier 2024-09-14 13:15:21 -07:00
mattmc3
0a1bf01574 docs: Update synopsis for 'set' 2024-09-14 10:29:44 +02:00
Johannes Altmanninger
5432ee1aa9 Relax history autosuggestion and highlighting if cd is wrapped
For implementation reasons, we special-case cd in several ways
1. it gets different completions (handle_as_special_cd)
2. when highlighting, we honor CDPATH
3. we discard autosuggestions from history that don't have valid path arguments

There are some third-party tools like zoxide that redefine cd ("function cd
--wraps ...; ...; end"). We can't support this in general but let's try to
make an effort.

zoxide tries to be a superset of cd, so special case 1 is still
valid but 2 and 3 are not, because zoxide accepts some paths
that cd doesn't accept.

Let's add a hack to detect when "cd" actually means something else by checking
if there is any --wraps argument.

A cleaner solution is definitely possible but more effort.

Closes #10719
2024-09-14 08:51:42 +02:00
Johannes Altmanninger
5b04f221a3 __fish_anypager: remove bat from default choice
As pointed out in
b83f3b0e98 (commitcomment-146189480)
bat is not actually useful. Also its (monochrome) output is unreadable on
my system.
2024-09-14 07:21:56 +02:00
Johannes Altmanninger
9eeed5ca12 Install fish-* man pages in default MANPATH
fish adds ~/.local/share/fish/man to its MANPATH for builtins etc.  But pages
like fish-doc are unambiguous so it seems like they should be accessible
from outside fish by default.

Closes #10711
2024-09-14 07:21:18 +02:00
Johannes Altmanninger
5ad7ab7b01 Clear some env variables in test env setup 2024-09-14 07:21:18 +02:00
Harmen
fc4dd8f4de docs: fix "theme choose None" command
The command needs an upper-case "None", not a lower case.
2024-09-13 12:21:34 +02:00
Theodor Tonum
5344576dc6 fix: pacman quiet typo 2024-09-13 09:59:56 +02:00
Kaley Main
a979b6341d Create a test that reproduces fish-shell/fish-shell#10703 2024-09-06 16:41:10 +02:00
Johannes Altmanninger
f8a720da8c Fix wildcard expansion doubling up "*/"
In some cases we add the wildcard twice.

    $ fish -c '../jj; complete -C"ls cli/*/conf/tem"'
    cli/*/*/config/templates.toml

Fix that. Test in the next commit.

There seems to be another bug in 3.7.1 where we fail to apply this completion
to the command line. This appears fixed. (FWIW we might want to revert
the quoting change in completion_apply_to_command_line(), maybe that one
accidentally fix this).

Fixes #10703
2024-09-06 16:41:10 +02:00
Fabian Boehm
325b51aca0 docs/set: Fix markup
Fixes #10697
2024-09-05 19:30:38 +02:00
Abel Chalier
65ab9e7bfc clearer wording on test.fish completions 2024-09-05 17:33:24 +02:00
may
79a9c0e0f2
add completions for git diff --color-moved and --color-moved-ws (#10698) 2024-09-03 18:00:17 -05:00
Johannes Altmanninger
77b2dcb462 Fix ctrl-c being ignored during builtin wait
Same as d21ed0fb2 (Disable terminal protocols before expanding wildcards,
2024-07-31).

Also mention a related issue in the changelog.
2024-09-01 14:08:01 +02:00
Johannes Altmanninger
15b08cbcab Make import style less noisy 2024-09-01 14:05:48 +02:00
Mahmoud Al-Qudsi
50a6dfd10d Replace a HashMap w/ a BTreeMap
The HashMap is used to generate the __fish_describe_command integration
completions. Given the nature of the allocations and the numbers that we use, a
BTreeMap would theoretically perform better. Benchmarks show a 2-9%
improvement in completion times consistently in favor of BTreeMap.
2024-08-31 14:13:41 -05:00
Mahmoud Al-Qudsi
73908f1218 fish_test_helper: Fix warnings about intentionally unused results
Warnings were appearing under GCC 13.2

(void) alone is insufficient under modern compilers, workaround with logical
negation taken from GCC bug tracker.
2024-08-31 13:16:51 -05:00
Mahmoud Al-Qudsi
ef6577db25 Update threads::thread_id() documentation 2024-08-31 12:57:13 -05:00
Mahmoud Al-Qudsi
c6bbacc703 Catch tls issues caused by linker bug
Worth including because mold is rather popular in the rust world and because the
bug affects mold versions coincident with the development of the fish rust port.

The bug affects all currently released versions of mold from 2.30.0 (Mar 2024)
onwards under at least FreeBSD (though quite likely other platforms as well).

See https://github.com/rui314/mold/issues/1338 for reference.
2024-08-31 12:48:15 -05:00
Fabian Boehm
c1d9f57107 CHANGELOG 2024-08-30 21:30:05 +02:00
Fabian Boehm
8ac06f5455 Comment why we need terminfo 0.9.0
This was attempted to relax in #10622, so before some poor packager
tries warn them against it.
2024-08-30 21:27:41 +02:00