Commit Graph

18427 Commits

Author SHA1 Message Date
ridiculousfish
3ce6a5fdd1 Make sets_bind_mode in input an Option<WString>
Previously this used an empty string to mean a sentinel; use an option instead.

Fixes a TODO.
2024-01-21 18:19:40 -08:00
ridiculousfish
b4b5cff3d8 Move input tests into their own module in the tests dir 2024-01-21 18:19:40 -08:00
Mahmoud Al-Qudsi
15a82b462f Remove unnecessary copies in build.rs 2024-01-21 17:20:38 -06:00
Johannes Altmanninger
38397734e2 Fix build on OpenSUSE Tumbleweed
Fix a search & replace gone wrong in 1234c77b1 (Support linking against
reentrant-configured curses, 2024-01-21).
2024-01-21 22:22:30 +01:00
Fabian Boehm
89282fd9bc Use CARGO_MANIFEST_DIR to see if we're running from build dir
This allows running a fish built from `cargo build` *and* built via
cmake.

In future, we should make this an optional thing that's removed from
installed builds.
2024-01-21 21:25:05 +01:00
ridiculousfish
3ecd835f58 Clean up some stale comments and restore libc usage in flog_safe
flog_safe should be explicitly async-signal-safe functions; let's avoid
nix in that module for this reason.
2024-01-21 12:03:56 -08:00
PolyMeilex
f3e8272c5d Move from libc read/write to nix read/write
Replace std from_raw_fd/into_raw_fd dance with nix write

Fixup notifyd build
2024-01-21 11:49:40 -08:00
Mark Huang
65cf6ada56 completions for apt and apt-get 2024-01-21 14:21:44 +01:00
Fabian Boehm
423829a634 Rename existing cache files
We're already moving them, we can remove the awkward dot that hides
them, and while we're doing that remove the useless $USER as well.

Most systems will have only one of these files - it's rare to run a
second package manager (especially for anything more than
bootstrapping a container).
2024-01-21 14:18:50 +01:00
Fabian Boehm
a66fa5262e Cache ykman completions
Also 140ms
2024-01-21 14:18:50 +01:00
Fabian Boehm
b4d9189fd3 Cache pip{,2,3,env} completions
These take a *lot* of time - `pip3` takes 180ms, `pipenv` takes 320ms
on my system.

Note that this removes a number of obsolete workarounds - pip's was
fixed in 2017 (and pip2 is less and less of a thing), pipenv's change
was in 2019.

Since these are packaging tools with access to the internet they
should really be kept up-to-date, so it is unlikely someone still uses
these old versions.
2024-01-21 14:18:50 +01:00
Fabian Boehm
e5b2c3e4be Add helper to cache | source completions
We have a lot of completions that look like

```fish
pip completion --fish 2>/dev/null | source
```

That's *fine*, upstream gives us some support.

However, the scripts they provide change very rarely, usually not even
every release, and so running them again for every shell is extremely
wasteful.

In particular the python tools are very slow, `pip completion --fish`
takes about 180ms on my system with a hot cache, which is quite
noticeable.

So what we do is we run them once, store them in a file in our cache
directory, and then serve from that.

We store the mtime of the command we ran, and compare against that for
future runs. If the mtime differs - so if the command was up or
downgraded, we run it again.
2024-01-21 14:18:50 +01:00
Fabian Boehm
7e087d8eda __fish_make_cache_dir: Create fish subdir and optionally deeper
This will move all current cache uses to e.g. ~/.cache/fish/

That's better anyway because it makes it easier to remove.

Also it allows supplying a subdir so you can do `__fish_make_cache_dir
completions`
to get ~/.cache/fish/completions.
2024-01-21 14:18:50 +01:00
王宇逸
2f373d839c Enable LTO 2024-01-21 13:31:13 +01:00
Fabian Boehm
120dc5c49f cmake: Include PushCheckState again
This was included in one file and used in another. Just include it here.
2024-01-21 12:17:33 +01:00
Fabian Boehm
8cf4d666b3 Remove more cmake configurechecks
PCRE2 is now handled by the crate, we don't need WCHAR_T_BITS anymore
2024-01-21 12:01:38 +01:00
Johannes Altmanninger
1234c77b15 Support linking against reentrant-configured curses
NCurses headers contain this conditional "#define cur_term":

	print  "#elif @cf_cv_enable_reentrant@"
	print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
	print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
	print  "#else"

OpenSUSE Tumbleweed uses this configuration option; For reentrancy, cur_term
is a function.  If the NCurses autoconf variable @NCURSES_WRAP_PREFIX@
is not changed from its default, the function is called _nc_cur_term.

I'm not sure if we have a need to support non-default @NCURSES_WRAP_PREFIX@
but if we do there are various ways;
- search for the symbol with the cur_term suffix
- figure out the prefix based on the local curses installation,
  for example by looking at the header files.

Fixes #10243
2024-01-21 11:26:07 +01:00
Johannes Altmanninger
5dfcfa336b edit_command_buffer: if aliasee is a recognized editor, pass cursor position too
If I alias "e" to "emacsclient" it will probably accept the same options.
Let's dereference the alias so we can detect support for passing the cursor
position in more cases.

This does not solve the problem for recursive cases (e.g. alias of another
alias). If we want to handle that we would need cycle detection.
2024-01-21 09:39:59 +01:00
Fabian Boehm
f7b541af99 tests/parse_util: Check against localized message
This is run in the current locale, without resetting to en_US.UTF-8
like our integration tests do.

So if you want to check for a specific message you need to check the
localized version.
2024-01-20 12:28:59 +01:00
Paul Ouellette
2cb60bed10 Remove share/completions/highlight.fish
Highlight ships its own completion script:
https://gitlab.com/saalen/highlight/-/blob/master/sh-completion/highlight.fish
2024-01-20 11:39:48 +01:00
Fabian Boehm
84b03c24d5 README: Remove chsh section
This is awkward because some systems really want $SHELL to be
sh-compatible, it's also duplicated with the actual docs and not
really something you have to do in the first five minutes of using
fish.

Supersedes #10229
2024-01-20 11:38:33 +01:00
Himadri Bhattacharjee
e014c981f2 Disallow background operator before && or ||
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

Closes #10228
Fixes #9911
2024-01-20 11:32:44 +01:00
Johannes Altmanninger
87d434a98d Improve failure message in test_error_messages 2024-01-20 11:30:13 +01:00
Johannes Altmanninger
c52c03b03c Fix clippy warnings 2024-01-20 11:30:13 +01:00
Johannes Altmanninger
2059e5a171 Allow finding for empty strings with wstr::find
I hit this temporarily in a test; it seems reasonable to allow this.
std::str does too.
2024-01-20 11:30:13 +01:00
Johannes Altmanninger
f356e2d82f Remove redundant fallbacks for installation dir variables
They are redundant as of a5e35abeb (build.rs: Default variables, 2024-01-15).
2024-01-20 10:26:54 +01:00
Fabian Boehm
e73d7e26e4 Remove some more cmake bits 2024-01-20 09:13:04 +01:00
Fabian Boehm
6f31ec7a61 Remove cmake policies
CMP0066: Honor per-config flags in try_compile() source-file
signature.

CMP0067: Honor language standard in try_compile() source-file signature.

We no longer have any try_compile
2024-01-20 09:02:43 +01:00
Mahmoud Al-Qudsi
2f30d8f949 Stop caching CURSES_LIBRARY_LIST
Just treat it as if we are building without cmake when it's not present.
2024-01-20 08:56:29 +01:00
Mahmoud Al-Qudsi
66a4beadce Simplify a few things in build.rs 2024-01-20 08:56:29 +01:00
Fabian Boehm
6be6890fa3 Remove config.h
We don't actually use anything in there anymore.

We keep the WCHAR_T_BITS define in cmake because that's
used to find pcre2.
2024-01-20 08:56:29 +01:00
Fabian Boehm
f0af165348 build.rs: Try ncurses if curses couldn't be found
That's gonna be the typical one
2024-01-20 08:56:29 +01:00
Fabian Boehm
5aa622daef Remove some more unused cmake bits 2024-01-20 08:56:29 +01:00
Fabian Boehm
cfeddcedb7 Remove unused bits from config.h 2024-01-20 08:56:29 +01:00
Fabian Boehm
a5e35abeba build.rs: Default variables
So we can build without cmake
2024-01-20 08:56:29 +01:00
ridiculousfish
9747ab19d1 Eliminate UVAR_FILE_SET_MTIME_HACK checks
This was previously limited to Linux predicated on the existence
of certain headers, but Rust just exposes those functions unconditionally. So
remove the check and just perform the mtime hack on Linux and Android.
2024-01-19 09:33:33 -08:00
ridiculousfish
70ed4806b4 Use libc O_EXLOCK instead of our own
Rust libc supports O_EXLOCK on supported platforms (BSD/macOS), use that instead
of re-exposing it.
2024-01-19 09:33:33 -08:00
Johannes Altmanninger
2ffec7463e build.rs: fix formatting 2024-01-19 09:18:02 +01:00
Johannes Altmanninger
7597288c18 test_error_messages: add back missing validation
Make sure to also look for the error part that occurs after the last format
specifier.

Still not great because it won't fail if there's unexpected output at the
beginning or end of the string.
2024-01-19 06:26:31 +01:00
Mahmoud Al-Qudsi
21b4a2e5d6 Simplify rsconf has_symbol() libc lookups 2024-01-18 18:22:07 -06:00
Mahmoud Al-Qudsi
a1147c7c4f Fix outdated build.rs comments 2024-01-18 18:10:47 -06:00
Ikko Eltociear Ashimine
1e925857f0 Update iwctl.fish
colum -> column
2024-01-18 19:34:30 +01:00
Johannes Altmanninger
800f2414fb Fix regression in split_string_tok()
If there's no more separator we break early but dont update pos, so we go
into the code path that asserts we have reached the limit.
2024-01-18 10:24:40 +01:00
Johannes Altmanninger
fff8e8163b Control-C to simply clear commandline buffer again
Commit 5f849d0 changed control-C to print an inverted ^C and then a newline.

The original motivation was

> In bash if you type something and press ctrl-c then the content of the line
> is preserved and the cursor is moved to a new line. In fish the ctrl-c just
> clears the line. For me the behaviour of bash is a bit better, because it
> allows me to type something then press ctrl-c and I have the typed string
> in the log for further reference.

This sounds like a valid use case in some scenarios but I think that most
abandoned commands are noise. After all, the user erased them. Also, now that
we have undo that can be used to get back a limited set of canceled commands.

I believe the original motivation for existing behavior (in other shells) was
that TERM=dumb does not support erasing characters. Similarly, other shells
like to leave behind other artifacts, for example when using tab-completion
or in their interactive menus but we generally don't.

Control-C is the obvious way to quickly clear a multi-line commandline.
IPython does the same. For the other behavior we have Alt-# although that's
probably not very well-known.

Restore the old Control-C behavior of simply clearing the command line.

Our unused __fish_cancel_commandline still prints the ^C. For folks who
have explicitly bound ^C to that, it's probably better to keep the existing
behavior, so let's leave this one.

Previous attempt at #4713 fizzled.

Closes #10213
2024-01-17 19:54:57 +01:00
Himadri Bhattacharjee
5389d84285 shorten long descriptions for the cargo command 2024-01-16 22:16:36 +01:00
Fabian Boehm
34c09b1816 reader: Fix infinite loop for up/downcase bindings
This could *probably* be rewritten nicer with a for-loop

Fixes #10222
2024-01-16 18:13:18 +01:00
Fabian Boehm
5d3aea363e Fix PagerAndSearch not focusing the search field
Boolean confusion

Fixes #10220
2024-01-16 16:39:05 +01:00
Johannes Altmanninger
fdc45452b6 Bump CMake version for IMPORTED_RUNTIME_ARTIFACTS
This was added in CMake 3.21 which is only 1.5 years old.
2024-01-15 21:35:06 +01:00
ridiculousfish
9bd4b3f878 Adopt count_newlines in additional places 2024-01-14 10:04:55 -08:00
ridiculousfish
4ea222cd34 Improve codegen of line_offset_of_character_at_offset
This function is a hotspot, but it has inefficient codegen:

1. For whatever reason, the chars() iterator of wstr is slower
   than that of a slice. Use the slice.

2. Unnecessary overflow checks were preventing vectorization.

Switch to a more optimized implementation.

This improves aliases benchmark time by about 9%.
2024-01-14 10:04:37 -08:00