Commit Graph

19288 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
66618d64cb Convert some lazy_static to OnceCell/OnceLock
These have clearer sync/unsync semantics and now ship with rust itself.
They don't paper over any possible cross-thread issues, and we can specifically
choose which we want for the purpose.
2024-05-16 20:33:43 -05:00
Mahmoud Al-Qudsi
0f18480559 Simplify Parser and EnvStack singletons and clarify thread semantics
`Parser` is a single-threaded `!Send`, `!Sync` type and does not need to use
`Arc` for anything. We were using it because that's all we had for the parser's
`EnvStack`, but though that is *technically* protected internally by a mutex
(shared with global EnvStack), there's nothing to say that other parsers with a
narrower scope/lifetime on other threads will be necessarily using the same
backing mutex.

We can safely marshal the existing `Arc<EnvStack>` we get from
`environment::principal()` into an `Rc<EnvStack>` since the underlying reference
is always valid. To prove this point, we could have PRINCIPAL_STACK be a static
`EnvStack` and have `environment::principal()` use `Arc::from_raw()` to turn
that into an `Arc<EnvStack>`, but there's no need to factorize this process.
2024-05-16 20:33:39 -05:00
Mahmoud Al-Qudsi
e4282f3798 Remove all locking from principal_parser()
By inverting the order of storage, we can use an `OnceCell`/`unsync::Lazy`
inside the Send/Sync `MainThread<T>` and remove the need for a lock altogether.
2024-05-16 14:23:25 -05:00
Fabian Boehm
5dc07c9e7e completions: More shortening
Also removes a few deprecated options - there's really no need to
offer these.
2024-05-16 18:29:42 +02:00
Johannes Altmanninger
29f2da8d18 Toggle terminal protocols lazily
Closes #10494
2024-05-16 12:26:47 +02:00
Johannes Altmanninger
6f9d5cf44c Address clippy lint 2024-05-16 12:25:29 +02:00
Mahmoud Al-Qudsi
b82170aded Change extract_prefix_and_unescape_yaml() assert!() to debug_assert!()
It's reasonable since this is only checking to see that the history file
contains the expected format and if it's corrupted but we at least got what we
expect to be the correct key/value pairs, then that's all we can do.

Of course the real motivation is to speed up this very hot function in any way
possible!
2024-05-15 22:42:19 -05:00
Mahmoud Al-Qudsi
51275525c1 Speed up extract_prefix_and_unescape_yaml
On the completions and history thread, the parent function
HistoryFileContents::decode_item() is responsible for ~60% of the CPU time, and
extract_prefix_and_unescape_yaml() alone comprising 14% (of the total).

This change removes allocations in the event that the history item is either
fully or partially plain yaml with no escapes to begin with, and brings down the
execution time of this function to only 7% of the total execution time.

The bulk of the remaining time is spent in wcs2string(), which is called
unconditionally and is naturally alloc-heavy.
2024-05-15 22:42:19 -05:00
ridiculousfish
caef202551 Fix some more clippies and enable more warnings 2024-05-15 20:05:35 -07:00
Fabian Boehm
fc5eb0a98a fish_for_bash_users: Put explanation on subshells first
and *then* explain things that aren't subshells.
2024-05-15 22:44:07 +02:00
Fabian Boehm
b6bebec513 docs: Simplify Combining Lists section
This was a bit dense.
2024-05-15 20:18:17 +02:00
Fabian Boehm
8bac13360b completions/gcc: More cleanup
These options, I tell you
2024-05-15 20:07:28 +02:00
Fabian Boehm
173bcf29ab completions/gcc: Cleanup options
- Remove duplicated options - we had `-type` 9 times!
- Remove deprecated options and synonyms
- Make descriptions shorter, even removing some - when they're inscrutable they might as well not be there.

Really, 99.8% of these options are of interest to nobody except possibly (a subset of) gcc developers, so it pays to have *less* on your screen that you don't use anyway.
2024-05-15 17:05:02 +02:00
Fabian Boehm
4cadaa4041 completions/gcc: Fix some options
Especially the "-l" one was *always* offered.
2024-05-15 17:05:02 +02:00
Johannes Altmanninger
35b689335a Strip control characters from pasted text
We ignore typed control characters 33a7172ee (Revert to not inserting control
characters from keyboard input, 2024-03-02).

We used to do the same for bracketed paste but that changed in 8bf8b10f6
(Extended & human-friendly keys, 2024-03-30) which made bracketed paste
behave like fish_clipboard_paste; it inserts the exact input (minus leading
whitespace etc). At that time it wasn't clear to me which behavior was the
right one (because of the inconsistency between terminal and bracketed paste).

As reported in
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$PEEOAoyJY-644amIio0CWmq1TkpEDdSy2QnfJdK-dco
trailing tabs in pasted text can be confusing.

There seems to be not real need to insert raw control characters into the
command line, so let's strip them when pasting.

Now the only way to insert a raw control character into the command line is
to recall it from command history.  Not sure what the behavior should be for
that case, we can revisit that later. If we get rid of raw control characters
entirely, then we can also delete the new "control pictures" rendering :)
2024-05-14 23:14:49 +02:00
Fabian Boehm
a72ba0408f CHANGELOG 2024-05-14 17:32:17 +02:00
Fabian Boehm
24836f9652 Use set --no-event in the key binding functions
This is how we can use it in a backwards-compatible way. Eventually we
would remove the compatibility guff.
2024-05-14 17:31:47 +02:00
Fabian Boehm
f1e19884fb Add set --no-event
This allows running `set` without triggering any event handlers.

That is useful, for example, if you want to set a variable in an event
handler for that variable - we could do it, for example, in the
fish_user_path or fish_key_bindings handlers.

This is something the `block` builtin was supposed to be for, but it
never really worked because it only allows suppressing the event for
the duration, they would fire later. See #9030.

Because it is possible to abuse this, we only have a long-option so
that people see what is up.
2024-05-14 17:31:47 +02:00
Fabian Boehm
403920e9d6 input: Remove all_mappings_cache
Replace it with a chained iterator.

This not only simplifies the code, but also removes a RefCell.
2024-05-14 16:14:02 +02:00
Mahmoud Al-Qudsi
e7f13ac329 Upgrade to rsconf 0.2.2
This version does not emit a warning for rustc-check-cfg for rustc <
1.80 and supports cfg names that include an underscore.
2024-05-13 16:36:27 -05:00
Fabian Boehm
e5d5e00969 Fix missing rename in build.rs 2024-05-13 20:04:08 +02:00
Mahmoud Al-Qudsi
ab68cf1eda Update build.rs formatting a bit 2024-05-13 11:34:07 -05:00
Johannes Altmanninger
a19ff4989a Prevent out-of-order execution following repaint
Commit a583fe723 ("commandline -f foo" to skip queue and execute immediately,
2024-04-08) fixed the execution order of some bindings but was partially
backed out in 5ba21cd29 (Send repaint requests through the input queue again,
2024-04-19) because repainting outside toplevel yields surprising results
(wrong $status etc).

Transient prompts wants to first repaint and then execute some more readline
commands, all within a single binding.  This was broken by the second commit
because that one defers the repaint until after the binding has finished.

Work around this problem by deferring input events again while a readline
event was queued. This is closest to the historical behavior.

The implementation feels hacky; we might find odd situations.
For example,

    commandline -f repaint end-of-line
    set token (commandline -t)

sets the wrong token.
Probably not a very important case. We could throw an error or make it work
by letting "commandline -t" drain the input queue.

That seems too complicated, better change repaints to not use the input queue
(and fake $status etc). Let's try to do that in future.

Closes #10492
2024-05-13 10:44:12 +02:00
ridiculousfish
d6e231af0d Fix some clippies 2024-05-12 14:55:35 -07:00
ridiculousfish
32ba8d93af Disable cd-without-permission test on macOS < 12
This allows the tests to pass on older macOS, before O_SEARCH was introduced.
2024-05-11 13:20:34 -07:00
ridiculousfish
172fb22692 Clean up and correct O_SEARCH definitions
Correct the FreeBSD constant and simplify some of the cfg() logic.
2024-05-11 13:20:34 -07:00
Jonathan Krebs
4606b02d44 rustfmt 2024-05-11 11:12:29 -07:00
Jonathan Krebs
07160e2f71 notice in CHANGELOG.rst 2024-05-11 11:12:29 -07:00
Jonathan Krebs
4eb0dd623d add testcase for cd without read permission 2024-05-11 11:12:29 -07:00
Jonathan Krebs
a148760963 cd: open directory with O_SEARCH or O_PATH, when the platform supports it 2024-05-11 11:12:29 -07:00
Jonathan Krebs
2ecbdb9ae7 cleanup: fds::open_dir - remove mode argument
[w]open_dir does not pass O_CREAT, so the mode argument to open is never used.
also, O_CREAT | O_DIRECTORY could not be used (portably) to create a directory.
(on POSIX does not specify what should happen, on Linux it is EINVAL.)
2024-05-11 11:12:29 -07:00
Fabian Boehm
e32efc0581 docs: Some rewording on completions 2024-05-10 17:40:18 +02:00
tesuji
f71623ec1b
Partially update zig completions for zig 0.13 (#10479)
Try for completeness with `zig -h` and `zig build -h`
2024-05-09 15:31:07 -05:00
Klaus Hipp
ae486bafc8
Add completions for VS Code preview builds (#10485) 2024-05-09 15:28:14 -05:00
Klaus Hipp
1c0887eba2
Add duf completions (#10486) 2024-05-09 15:27:13 -05:00
Klaus Hipp
5524b46181
Add zed completions (#10487) 2024-05-09 15:25:41 -05:00
Mahmoud Al-Qudsi
a7bde3921b build.rs: Use rsconf::declare_dependency()
This new feature in rsconf 0.2.0 resolves the compile-time warnings we get under
rustc 1.80+ about unrecognized cfg names by informing cargo of all valid cfg
names/values even when the cfg in question isn't enabled.
2024-05-09 14:22:27 -05:00
Mahmoud Al-Qudsi
2faf1159fa Upgrade to rsconf 0.2.0 2024-05-09 14:20:57 -05:00
Mahmoud Al-Qudsi
35a16e3713 Rename FISH_TSAN_WORKAROUNDS and add feature to Cargo.toml
rustc 1.80 now complains about features not declared in Cargo.toml and cfg
keys/values not declared by build.rs to protect against typos or misuse (you
think you're using the right condition but you're not). See
rust-lang/cargo#10554 and rust-lang/rust#82450.

(We're not actually using TSAN under CI at this time, but I do want to re-enable
it at some point — especially if we get multithreaded execution going — using
the rust-native TSAN configuration.)

I'll be updating the `rsconf` crate and patching `build.rs` accordingly to also
handle the warnings about unknown cfg values, but tsan is a feature and not a
cfg and these can be dealt with in `Cargo.toml` directly.
2024-05-09 13:58:42 -05:00
Mahmoud Al-Qudsi
059b842d1b is_wsl(): Move .copied() earlier in the iter pipeline
This is a best practice that usually helps with auto vectorization, as llvm has
a hard time seeing through the references.
2024-05-09 13:33:50 -05:00
Mahmoud Al-Qudsi
5dcc5955fb Don't allocate a vector twice in wcs2zstring()
We were passing a slice (and not a vec) to `CString::new()`, meaning it would
allocate a new Vec internally to hold the bytes.

Also document that the resulting CString will be silently truncated at the first
interior NUL.
2024-05-09 13:19:06 -05:00
Mahmoud Al-Qudsi
883bcbad83 Remove possible panic from wperror() 2024-05-09 11:20:09 -05:00
Mahmoud Al-Qudsi
84be043f31 Clean up src/libc.rs some
Update the CVAR!() macro and use it more.
2024-05-08 22:34:10 -05:00
Mahmoud Al-Qudsi
2ca92cd52d completions/rustup: Filter out installed components from rustup component add 2024-05-08 18:47:15 -05:00
Mahmoud Al-Qudsi
671d128a3e completions/rustup: Fix incorrect component names
The components with the form abc-x86_64-unknown-linux-gnux32 were ending
up generating invalid components of the form abcx32, which is incorrect.
2024-05-08 18:43:28 -05:00
Fabian Boehm
9e6a661c00 One more sleep 2024-05-08 16:35:00 +02:00
Fabian Boehm
01bbdb02ae Upgrade terminfo to 0.9.0
Should also fix the macos CI failures
2024-05-08 15:46:41 +02:00
Mahmoud Al-Qudsi
92eee61fb5 Convert colors::Flags to a bitflags enum
We use accessors and setters for all operations, so there's no benefit to
storing the modifiers as separate boolean fields.
2024-05-07 14:03:38 -05:00
Fabian Boehm
41a0fe2b1d history: Check for cmd key earlier
This shows up hot in `perf record ./fish` style profiles.

This assumes that "- cmd" can't be escaped.
2024-05-07 20:23:32 +02:00
Mahmoud Al-Qudsi
f709795a3a Reserve vector capacity upfront in colors::named_color_names()
Only because why not.
2024-05-07 13:09:40 -05:00