Commit graph

19515 commits

Author SHA1 Message Date
Fabian Boehm
f0a5f8738b Silence clippy lints 2024-11-24 11:17:34 +01:00
Mahmoud Al-Qudsi
1347df898e Add ascii fast path for fish_wcswidth(&wstrw)
chars.all(|c| c.is_ascii()) is autovectorizable but this outperforms even when
it's not vectorized.
2024-11-22 21:35:39 -06:00
Mahmoud Al-Qudsi
2fd51355c3 Speed up wcscasecmp by approximately 30-40%
Moving the "make empty ToLowercase iterator" logic to within the
`unwrap_or_else()` instead of always generating it brings most of the speedup;
unrolling the recursive call brings in the rest.
2024-11-22 21:34:25 -06:00
Mahmoud Al-Qudsi
8c8da78cf8 Speed up get_case_fold() 5x
Using `c.is_uppercase()` instead of getting the iterator and checking if the
first (and only) lowercase letter of the sequence is the same as the original
input is 5-8x faster (measured via criterion against `/usr/share/dict/words`).

(Additional benefit of forcibly inlining the now iterator-based comparison not
taken into account; this necessitated changing from a closure to a local
function as the inline attribute on closures is not yet supported with the
stable compiler toolchain.)
2024-11-22 16:30:10 -06:00
Mahmoud Al-Qudsi
b949497bc1 Use idiomatic names for CaseSensitivity and ContainType 2024-11-22 16:28:33 -06:00
Mahmoud Al-Qudsi
b570c7f6a6 Reduce allocations when deduping completions in place
This is still suboptimal because we are allocating a vector of indices to be
removed (but allocation-free in the normal case of no duplicates) but
significantly better than the previous version of the code that duplicated the
strings (which are larger and spread out all over the heap).

The ideal code (similar to what we had in the C++ version, iirc) would look like
this, but it's not allowed because the borrow checker hates you:

```
fn unique_in_place_illegal(comps: &mut Vec<Completion>) {
    let mut seen = HashSet::with_capacity(comps.len());
    let mut idx = 0;
    while idx < comps.len() {
        if !seen.insert(&comps[idx].completion) {
            comps.remove(idx);
            continue;
        }
        idx += 1;
    }
}
```
2024-11-22 14:11:01 -06:00
Fabian Boehm
36c5ee045c fixup! filter control sequences 2024-11-21 21:20:35 +01:00
Fabian Boehm
2d07aa2686 tests: Move control sequences filtering to fish directly
This was an sh-script that just invoked fish again.

I can see how we could implement it in another language to avoid the
fish under test corrupting the results, but it literally invoked the
fish under test anyway.
2024-11-21 21:08:56 +01:00
Fabian Boehm
8dcde27e0b functions/history: Put back some checks for clear{,-session}
Mostly we pass on the options - otherwise they would be ignored.

For `clear`, we do need the full checks, because that will
prompt *before* running the builtin.

But this makes it easier to eventually move that logic into the builtin
2024-11-21 18:55:03 +01:00
Fabian Boehm
212dd6ec37 builtins/history: Use the enum nicer
Name it so it's not SHOUTY CASE, make a `panic!` unrepresentable

No functional change
2024-11-21 18:33:32 +01:00
Fabian Boehm
fcab68c591 docs/faq: Fix some broken keys 2024-11-21 18:28:43 +01:00
Fabian Boehm
6fe192606a functions/history: Set variables in function-scope explicitly
```fish
set -g LESS foo

history search bar
```

changes the global $LESS and exports it.
2024-11-21 18:27:10 +01:00
Fabian Boehm
11f11e27a1 functions/history: Remove unnecessary code
These things are all handled in the builtin
2024-11-21 18:26:47 +01:00
Kid
31b15405e9
Add completion for path basename -E/--no-extension (#10863) 2024-11-20 15:06:53 -06:00
Mahmoud Al-Qudsi
edd82be58d Fix crash on invalid CSI parameters
If a semicolon-delimited list of CSI parameters contained an (invalid) long
sequence of ascii numeric characters, the original code would keep multiplying
by ten and adding the most recent ones field until the `params[count][subcount]`
u32 value overflowed.

This was found via automated fuzz testing of the `try_readch()` routine against
a corpus of some proper/valid CSI escapes.
2024-11-20 15:01:34 -06:00
Mahmoud Al-Qudsi
b92830cb17 Change readch() into try_readch()
This lets us call into the entirety of the prior `readch()` with an exhaustible
input stream without panicking on the `unreachable!()` call. The previous
functionality is kept under the old name by calling `try_readch()` with the
`blocking` parameter set to `true` (100% same behavior as before).

While the `try_readch(false)` entrypoint isn't used directly by the current fish
codebase, it is required in order to automate input reader tests without the
overhead and complexity of running the test harness in a tty emulator emulator
like pexpect or tmux, which moreover necessitates out-of-process testing – which
is incompatible with most perf-guided testing harnesses.

I hope to be able to upstream harness integrations using this entry point in the
near future.
2024-11-20 14:53:07 -06:00
Fabian Boehm
b3108c0cee CHANGELOG 2024-11-19 21:12:44 +01:00
Fabian Boehm
7a667b4f6d Add basic completions for firejail
These are pretty basic, but get us roughly up to the level of the
official completions (that are also incomplete and offer disabled
options).

Fixes #10858
2024-11-18 16:16:07 +01:00
Peter Ammon
c4bc6b6f09
Clean up print_help
`print_help` is a hacky-wacky function used to support the `--help` command
of `fish_key_reader` and others. The Rust version panics on an error; fix
that and make it print more useful help messages.
2024-11-17 17:03:34 -08:00
Unbelievable Mystery
262e2d5fe6
Update completions for: wine (#10789)
* feat(function): move cmd completion function to a separate file

* feat(completion): support wine cmd subcommand

* feat(completion): support wine control subcommand

* feat(completion): support wine eject subcommand

* feat(completion): support wine explorer subcommand

* feat(completion): support wine explorer subcommand for desktops

* feat(completion): support wine start subcommand

* feat(completion): support wine winemenubuilder subcommand

* feat(completion): support wine winepath subcommand

* fix(function): rename function for cmd argument completion

* feat(function): implement function to complete registry keys

* feat(completion): support wine regedit subcommand

* feat(function): add top-level key descriptions

* fix(completion): remove redundant comment

* feat(completion): support wine msiexec subcommand

* refactor(completion): group code into functions

* feat(completion): enhance subcommand descriptions
2024-11-17 14:58:21 -08:00
Unbelievable Mystery
93aa5a9376
Add completions for: guile, guild (#10792)
* feat(completion): support guile command

* feat(completion): support guild command

* feat(completion): support guild subcommand

* feat(completion): squeeze code
2024-11-17 14:08:19 -08:00
Peter Ammon
642eff9e1f
Fix some clippies and remove some dead code 2024-11-17 12:37:45 -08:00
Next Alone
723e5a8417 completions(ollama): ollama need no files as i know (#10851)
Closes #10851.

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
2024-11-17 10:05:42 -06:00
David Adam
0e6171b63e CHANGELOG: work on 4.0.0 2024-11-17 23:12:46 +08:00
David Adam
98fcb1c6ba completions/diskutil: list all volumes, not just the writeable ones
Discussion in #10574.
2024-11-17 22:06:54 +08:00
Xiretza
421e27b1bf Add completions for iftop 2024-11-17 21:59:08 +08:00
Johannes Altmanninger
13f0c9b0c6 Remove accidentally added file 2024-11-17 05:20:35 +01:00
Johannes Altmanninger
2d8fcbcdcd Fix regression causing mbrtowc(argv) to be called before setlocale()
Fixes #10847
2024-11-16 20:46:06 +01:00
Mahmoud Al-Qudsi
68b9f96f84 Add completions for simonw/llm 2024-11-16 13:27:29 -06:00
Johannes Altmanninger
913860bd1c Fix regression causing alt-right to stop at autosuggestion
Fixes #10839
2024-11-16 13:05:44 +01:00
Johannes Altmanninger
ca21872d14 Clean up the accept-autosuggestion code path a little bit
It's still a bit too complex unfortunately.
2024-11-16 13:05:44 +01:00
vp2177
2b19e1a09b
completion(apt-mark): Add missing minimize-manual command & --color options (#10825)
* Update apt-mark.fish
2024-11-14 16:01:54 -06:00
Mahmoud Al-Qudsi
cdeb3977c3 Re-enable tmux-prompt test under FreeBSD
It passes now that we have uvar notifications working under BSD.
2024-11-14 13:44:49 -06:00
Mahmoud Al-Qudsi
fea1e3aee5 Use iterators to clean up disown logic 2024-11-14 13:25:25 -06:00
Mahmoud Al-Qudsi
c1acbf2845 Deduplicate jobs passed to disown builtin
I'm guessing this was missed in the port because there were comments referencing
using a hash set to perform the deduplication but there was no hashset. (The
TODO was added later.)
2024-11-14 13:24:55 -06:00
Fabian Boehm
366c1b7210 Refuse to search history pager if no new results exist
This prevents searching further and collapsing results into one.

Now I need to figure out how to get it to flash.
2024-11-14 20:02:49 +01:00
Mahmoud Al-Qudsi
4061ef7137 Remove unnecessary Pid::get() calls 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
fc47d9fa1d Use strongly typed Pid for job control 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
2cf4b12d41 Use strongly typed Option<Pid> for event handler
This caught an incorrect description for process/job exit handlers for ANY_PID
(now removed) which has been replaced with a message stating the handler is for
any process exit event.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
95ac51101e Use Option<Pid> instead of Option<pid_t>
Statically assert that the interior value is both positive and non-zero.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
3307672998 Use type safety for pid values
The previous approach of "treat this field as an `Option<NonZeroU32>` and
remember to check `p.has_pid()` before accessing it" was a mix of C++ and rust
conventions and led to some bugs or incorrect behaviors.

* `jobs -p` would previously print both the (correct) external pid and the
  (incorrect) internal value of `0` if a backgrounded command contained a
  fish function (e.g. `function foo; end; cat | foo &; jobs`)
* Updating/calculating job cpu time and usage was incorrectly including all of
  fish's cpu usage/time for each function/builtin member of the job pipeline.

Closes #10832
2024-11-14 13:02:03 -06:00
Fabian Boehm
080e40aac0 Fix crash in history pager
ctrl-r ctrl-s ctrl-s

Attemps to go before the beginning and asserts out. Instead refuse to
do that.

(there's some weirdness where it can reduce the pager to the first
entry if you keep pressing, which I haven't found yet, but that's better than *crashing*)
2024-11-14 16:36:40 +01:00
Fabian Boehm
7846a232a9 cmake: Add some new version gunk
CMake Warning (dev) at cmake/Tests.cmake:56 (add_custom_command):
  Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.  Assuming
  POST_BUILD to preserve backward compatibility.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

So we just keep it the same.
2024-11-13 17:48:15 +01:00
Fabian Boehm
6d76b938c7 bind: Remove "c-" and "a-" shortcut notation
These are another way to spell the same thing that doesn't match what
`bind` would print.

They're also not documented and tested thoroughly.

Since they are just small shortcuts and unreleased we can just remove
them.

Fixes #10845
2024-11-13 17:48:15 +01:00
Mahmoud Al-Qudsi
14a5c0ca44 Disable tmux-multiline-prompt under macOS CI 2024-11-12 17:13:18 -06:00
Mahmoud Al-Qudsi
bb57f2391f Fix a bad comment and clarify delta behavior
s/fish/delta/ and provide a better explanation.
2024-11-12 09:59:10 -06:00
Mahmoud Al-Qudsi
d33cbfd1a3 Prevent delta completions from complain with old version 2024-11-11 16:51:27 -06:00
Mahmoud Al-Qudsi
4e3dc51bc4 Prevent test suite from hanging on panic 2024-11-11 16:45:13 -06:00
Fabian Boehm
960415db3f function: Error out for read-only variables
This will refuse to define the function instead of defining it with an
unusable argument.

Fixes #10842
2024-11-11 17:56:57 +01:00
Fabian Boehm
0ef811c86e dir_iter: Remove duplicate NUL-removal
This goes over the d_name twice.

Filenames already cannot contain NUL (the C-api cannot express it!), so we don't need to scan them.
2024-11-11 17:56:57 +01:00