Commit Graph

19496 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
5ca76564a4 Store BlockData in a Box
We almost never access any of this and having it stored directly in the `Block`
struct increases its size (reducing how many we can fit in L1 and L2, and
increasing memory copy traffic).

Gets rid of BlockData::None so we can avoid allocating a Box at all when we have
no data (at the cost of yet-another-wrapper-type), which is the usual case.
2024-06-01 11:41:32 -05:00
Mahmoud Al-Qudsi
1d159277c6 Move Block fields specific to certain block types to separate enum
This has a few advantages,
* We now statically assert that all fields used by a particular block type are
  correctly initialized (i.e. you can't assign the function name but forget to
  assign its arguments),
* Conversely, we can match directly on `BlockData` and be guaranteed that the
  fields we want to access are initialized and present,
* We reduce the number of assertions, effectively "unwrapping" only once based
  off the block type instead of each time we try to access a conditional field,
* We reduce the size of the `Block` struct by coalescing fields that cannot
  co-exist, bringing it down from 104 bytes to 88 bytes.

It would be nice to make all of `Block` itself an enum, but it currently
requires `Copy` and we take advantage of that to copy it around everywhere.
Putting these fields directly in `Block` directly would mean a lot more memory
traffic just checking block types.
2024-06-01 11:15:19 -05:00
Mahmoud Al-Qudsi
0246c938ca Coalesce BlockType::function_call and BlockType::function_call_no_shadow
There's no need for two separate block types when one is merely a variant of the
other. This may have been required under C++ but thanks to sum types (rust's
enums) we don't need to do that any more.
2024-05-31 20:53:52 -05:00
Mahmoud Al-Qudsi
fc9a743622 completions/env: overhaul completions
The value completions were rendered almost entirely useless due to the forced
inclusion of file completions at all tokens, including in the head/command
position thanks to the use of `__fish_complete_subcommand` which doesn't
understand the semantics of `env` and expects something like `ssh`. But we don't
need it at all.
2024-05-31 20:49:48 -05:00
Mahmoud Al-Qudsi
6ec09260dd Changelog: document #5263 and provide workaround
[ci skip]
2024-05-31 16:21:24 -05:00
Mahmoud Al-Qudsi
417e89a4b3 Work around WSLv1 not properly cleaning up stopped orphaned jobs
See #5263.
2024-05-30 21:31:04 -05:00
Mahmoud Al-Qudsi
6c944debec Send signals in the correct order in hup_jobs()
If the backgrounded/stopped job was using the tty, sending it SIGCONT first
might cause it to immediately wake and try to use the tty (which fish still has
control over), causing it to immediately stop again after receiving a SIGTTOU.

We are supposed to send SIGHUP first so that when the process resumes it sees
the queued SIGHUP and executes its registered handler!
2024-05-30 18:26:13 -05:00
Mahmoud Al-Qudsi
e1ee193822 Speed up __fish_make_cache_dir
Don't fork/exec an external process, especially one performing IO, if we don't
have to.

This, in turn, speeds up __fish_source_cached_completions which is rather slow
under WSL (and slower than it needs to be on other platforms).
2024-05-30 17:03:03 -05:00
Mahmoud Al-Qudsi
98642d307a Don't use a graphical browser under SSH
...unless X is also being forwarded.

Someone else will have to figure out the Wayland equivalent (if that even
exists). Not my monkey, not my circus.
2024-05-30 16:15:07 -05:00
Mahmoud Al-Qudsi
7d77d7aa84 Convert more block iteration methods to use iterators 2024-05-30 15:54:54 -05:00
Fabian Boehm
0a8fd05bb0 docs/fish_add_path: Reword description
Use "directories" explicitly instead of "components" to make it more
clear that the arguments need to be directories, not files.

Also a bit on intent and variable scope.
2024-05-30 22:52:03 +02:00
Mahmoud Al-Qudsi
f6200224fc Use Iterator::count() to check function stack depth 2024-05-30 12:49:28 -05:00
Mahmoud Al-Qudsi
b495cffa50 fixup! Add workaround for targets with too small a main stack size 2024-05-30 12:25:06 -05:00
Mahmoud Al-Qudsi
a3e0d64e88 Remove usage of env -u
`env -u` is not supported on all platforms we support (e.g. macOS/OS X 10.10).
We don't need these variables erased, blanked works just fine.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
4b840075f4 Patch cd.fish test to support older macOS versions
The sysctl kern.osproductversion is not available on the oldest versions
we support.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
57f558578b Add workaround for targets with too small a main stack size
pthread_get_stacksize_np() is buggy on legacy OS X; make sure you are building
fish with a rust toolchain that correctly patches these functions.

See https://github.com/macports/macports-legacy-support/pull/86
2024-05-30 12:14:37 -05:00
Mahmoud Al-Qudsi
46f6aa8024 Update ssh-keygen completions
Don't run `ssh` upon sourcing and don't rely on `ssh -Q` being available.
2024-05-29 14:08:21 -05:00
Mahmoud Al-Qudsi
828b88a212 Add issue reference to flatpak completion workaround
[ci skip]
2024-05-29 13:54:39 -05:00
Mahmoud Al-Qudsi
7bf3b57e47 Fix buggy test_pthread() condvar test
There's no guarantee that a condition variable is stateful. The docs for
`Condvar::notify_one()` actually say the opposite:

> If there is a blocked thread on this condition variable, then it will be woken
> up from its call to wait or wait_timeout. Calls to notify_one are not buffered
> in any way.

This test was relying on the main loop obtaining the lock and entering the
condition variable sleep before the thread was scheduled and got around to
notifying the condition variable. If this non-deterministic behavior was not
upheld, the test would time out since it would obtain the lock (either before or
after the variable were updated) then call `condvar.wait()` *after* the variable
had been updated and the condvar signalled, but without (atomically or even at
all) checking to see if the desired wake precondition was fulfilled. As the
child thread had already run and the wake notification was NOT buffered, there
was nothing to wake the running thread.

There really wasn't any way to salvage the test as originally written, since the
write to `ctx.val` was not in any way linked to the acquire/release of the mutex
so regardless of whether or not the main thread obtained the mutex and checked
the value precondition before calling `condvar.wait()`, the child thread's write
could have happened after the check but before the wait() call. As such, the
test has been rewritten to use `wait_while()` but then also updated to bail in
case of a timeout instead of hanging indefinitely (since neither the `ctest`
runner nor the `cargo test` harness was timing out; `cargo test` would only
report that the test had exceeded 60 seconds but as long as it was not executed
with `cargo test -- -Z --ensure-time` (which is only available under nightly),
the test would not halt.

If this test were *intentionally* written to test the scenario that was timing
out, it should be written deterministically in such a way that the main loop
did not run until after it was guaranteed that the variable had been updated
(i.e. by looping until val became 5 or waiting for an AtomicBool indicating the
update had completed to be set), but I'm not sure what the benefit in that would
be since the docs actually guarantee the opposite behavior (the notified state
is explicitly not cached/buffered).

If we have fish code written with the assumption that condvar notifications
prior to *any* call to `Condvar::wait()` *are* buffered, then that code should
of course be revisited in light of this.
2024-05-29 13:13:13 -05:00
Johannes Altmanninger
390b40e02b Fix regression not refreshing TTY timestamps after external command from binding
Commit 8a7c3ce (Don't abandon line after writing control sequences, 2024-04-06)
was broken by 29f2da8 (Toggle terminal protocols lazily, 2024-05-16), fix that.

Fixes #10529
2024-05-29 12:57:09 +02:00
Mahmoud Al-Qudsi
8c364dc949 CHANGELOG: Fix awkwardly formatted issue reference
The :issue:`xxxx` template generates text in the format (#xxxx), so this was
rendering as "... See (#xxxx)." which is just weird.

[ci skip]
2024-05-28 11:53:36 -05:00
Mahmoud Al-Qudsi
5b7fd61867 Fix single-backtick-quoted code expressions in CHANGELOG.rst
Reminder that reStructuredText is awkward and you can't make sphinx treat these
as inline code; they'll be formatted as italic text only.

Vim search expression:
    \([`:]\)\@<!`[^`:]\+`\(`\)\@!

Followed by
    ysi``

does the trick quite nicely.
2024-05-28 11:47:45 -05:00
Mahmoud Al-Qudsi
8b1c8ed791 CHANGELOG: Add #10506 and #10521 2024-05-28 11:09:09 -05:00
Yuntao Zhao
96416cc49e
feat: improve completion for konsole (#10528)
* feat: improve konsole completion

* Improve konsole profile completion to be dynamic

Directly complete --profile as a long argument

* Dynamically complete konsole -p
2024-05-28 10:26:03 -05:00
Fabian Boehm
f06143c11a docs: Fix some formatting 2024-05-27 23:21:06 +02:00
ridiculousfish
29b620b56c Remove an unused type 2024-05-27 11:45:25 -07:00
ridiculousfish
9e406e4fbc Silence some clippies 2024-05-27 11:07:02 -07:00
Mahmoud Al-Qudsi
6117b5071c Don't ignore assert_sorted_by_name doctest 2024-05-27 10:20:24 -05:00
Fabian Boehm
7850142bef printf/tests: Use c_char instead of i8
Breaks on arm again
2024-05-27 12:47:51 +02:00
Nguyen Huu Kim
8880fa8dd7
feat: add completions for k8s tools (kustomize, flux) (#10473)
* feat: add completions for kustomize

* feat: add completions for FluxCD

* Update flux.fish

* Update kustomize.fish

---------

Co-authored-by: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2024-05-26 22:12:49 -05:00
Mahmoud Al-Qudsi
f84b1993ec Add path basename -E tests 2024-05-26 22:06:11 -05:00
Mahmoud Al-Qudsi
6091d1149f Document path basename -E 2024-05-26 22:06:11 -05:00
Mahmoud Al-Qudsi
286fa4bf5b Add path basename --no-extension
This makes `path basename` a more useful replacement for the stock `basename`
command, which can be used with `-s .ext` to trim `.ext` from the base name.

Previously, this would have required the equivalent of

    path change-extension "" (path basename $path)

but now it can be just

    path basename -E $path
2024-05-26 22:06:11 -05:00
Mahmoud Al-Qudsi
dbf6dfd5d2 completions/flatpak: dynamically complete flatpak install 2024-05-26 22:03:27 -05:00
Mahmoud Al-Qudsi
4868166f86 completions/rustc: preserve trailing = in -Z values 2024-05-26 21:44:02 -05:00
Mahmoud Al-Qudsi
84d057e7b7 Finish refactoring rustc completions
* Properly handle a lot more -Z completion formats as suggested by `rustc -Z
  help`
* Don't run any `rustc` commands when sourcing `rustc.fish`; these invocations
  are instead deferred until the user attempts to complete the specific switch.
* Support CSV -A/F/D/W values
2024-05-26 21:33:48 -05:00
Mahmoud Al-Qudsi
9045b251b0 Fix missing -- filter in string replace call 2024-05-26 21:33:48 -05:00
tesuji
114856e1d9
git: add --reuse-message and --reedit-message completion (#10530) 2024-05-26 20:57:43 -05:00
ridiculousfish
94f13a50f5 Add musl libc to our license.rst
The new printf is derived from musl libc. Add it to license.rst to reflect our
usage.
2024-05-26 16:07:27 -04:00
ridiculousfish
f16a1361c5 Adopt the new printf crate
This drops our usage of printf-compat.
2024-05-26 16:07:27 -04:00
ridiculousfish
585dac6b08 Use cargo test --workspace
Allows running printf tests.
2024-05-26 16:07:27 -04:00
ridiculousfish
7002571cf8 Add printf crate to workspace
This adds a crate containing a new implementation of printf, ported from musl.

This has some advantages:

- locale support is direct instead of being "applied after".
- No dependencies on libc printf. No unsafe code at all.
- No more WideWrite - just uses std::fmt::Write.
- Rounding is handled directly in all cases, instead of relying on Rust and/or
  libc.
- No essential dependency on WString.
- Supports %n.
- Implementation is more likely to be correct since it's based on a widely used
  printf, instead of a low-traffic Rust crate.
- Significantly faster.
2024-05-26 16:07:27 -04:00
Fabian Boehm
b9b7dc5f6c fmt 2024-05-26 10:50:45 +02:00
Fabian Boehm
52d1806e1f Apply some manual clippy lints
Mostly replacing std::<type>::MAX with <type>::MAX.

Surprising here is replacing

.expect(format!(...))

with

.unwrap_or_else(|_| panic!(...))

It explains that this is because the "format!" would always be called.
2024-05-26 10:45:46 +02:00
Fabian Boehm
20830744a9 Apply some clippy lints
Nothing too surprising, mostly removing useless references and lambdas
2024-05-26 10:37:37 +02:00
Fabian Boehm
2c3894993f Remove errant profiling enabling
This enabled the profile in fish_setlocale, which caused startup
profile to always be on, so

```fish
fish --profile file -c 'foo'
```

would show the entire startup as well
2024-05-26 10:32:28 +02:00
ridiculousfish
08f8983085 Adopt the new hex float parsing
This eliminates hexponent.
2024-05-25 18:39:45 -07:00
ridiculousfish
bed2ff2ea6 Add homegrown hex float parsing
Hex float parsing may come about through wcstod, for example:

    printf "%f" '0x8p2'

should output 32.0.

Currently we use a not-great fork of hexponent. Hexponent has been dormant for
years, and has some issues: doesn't round properly, allocates unnecessarily,
doesn't handle denormals, is more complicated than necessary.

Just rewrite hex float parsing, fixing those problems and getting us off of this
weird fork.
2024-05-25 18:31:38 -07:00
Fabian Boehm
1d0f1d2697 fmt 2024-05-25 22:21:52 +02:00
Fabian Boehm
d5101e1923 set: Put back zero-index error instead of crashing
This was missed in the initial port in 77aeb6a2a8.
2024-05-25 21:32:40 +02:00