Commit Graph

17405 Commits

Author SHA1 Message Date
Fabian Boehm
1a52f79c24 docs/test: More on THE PROBLEM 2023-07-06 18:39:42 +02:00
may
e3e7ab77ad add stash completions to git show and git diff 2023-07-05 10:53:17 +08:00
David Adam
87307775fc fds: add comment on O_CLOEXEC fallback being dropped 2023-07-05 10:30:27 +08:00
ridiculousfish
bee422fea2 Use a faster, deterministic RNG in the string escape tests
This shaves about 9 seconds off of the runtime, and makes the test
deterministic.

We do not touch the test_convert test because there is a known failure and we
need to track it down before making it deterministic.
2023-07-04 13:27:53 -07:00
ridiculousfish
0bfe83ce88 Replace write! calls with explicit hex formatting
Rather than relying Rust's formatting, just compute the hex chars directly.

This shaves about 6 seconds off of the test runtime.
2023-07-04 13:27:53 -07:00
ridiculousfish
c48c0bb226 Replace sprintf call with write!
This reduces the time for the Rust tests from a few minutes to ~40 seconds.

Also fix some bogus comments which were ported from C++.
2023-07-04 13:27:53 -07:00
ridiculousfish
b16f617fb3 Migrate string and lock tests into their own files
Get some stuff out of the common module, which is growing large.

Also migrate the tests into "native" Rust tests so they will run in parallel.
We have to use an explicit setlocale() call to get a multibyte locale, for the
"crazy" tests.
2023-07-04 13:27:53 -07:00
Henrik Hørlück Berg
69ed2d1ca7 Fix built for newer than linked macOS warning 2023-07-04 13:27:53 -07:00
ridiculousfish
eaf8e73c42 Make escape/unescape string_var hew more closely to the C++ 2023-07-04 13:27:53 -07:00
Henrik Hørlück Berg
970ed610df Avoid string copying to speed up asan 2023-07-04 13:27:53 -07:00
Henrik Hørlück Berg
595d593732 Fully migrate to Rust escape string tests and code
Co-Authored-By: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2023-07-04 13:27:53 -07:00
Henrik Hørlück Berg
0a4bcf7430 Port (un)escape-tests, fix a couple bugs 2023-07-04 13:27:53 -07:00
ridiculousfish
ec28a30bd6 Fix a clippy lint warning 2023-07-04 13:26:19 -07:00
ridiculousfish
35f8f421fe topic_monitor to migrate from wperror to perror
This avoids needing to use the ffi
2023-07-04 13:26:19 -07:00
ridiculousfish
15361f62ed signal.rs to stop using wperror
This needed to cross the ffi which is annoying in tests. Use the Rust perror()
instead.
2023-07-04 13:26:19 -07:00
ridiculousfish
1076642770 Remove future_feature_flags_init
Make Features just a global. After the Rust port we can make it use atomics and
no longer be mut.

This allows feature flags to be used in Rust tests.
2023-07-04 13:26:19 -07:00
ridiculousfish
37fed01642 FLOG to stop depending on the ffi
Prior to this commit, FLOG used the ffi bridge to get the output fd. Invert
this: have fish set the output fd within main. This allows FLOG to be used in
pure Rust tests.
2023-07-04 13:26:19 -07:00
Johannes Altmanninger
052823c120 history pager: delete selected history entry with Shift-Delete
After accidentally running a command that includes a pasted password, I want
to delete command from history. Today we need to recall or type (part of)
that command and type "history delete".  Let's maybe add a shortcut to do
this from the history pager.

The current shortcut is Shift+Delete. I don't think that's very discoverable,
maybe we should use Delete instead (but only if the cursor is at the end of
the commandline, otherwise delete a char).

Closes #9454
2023-07-04 18:42:11 +02:00
Johannes Altmanninger
857612d243 Simplify logic for special input functions "and" & "or"
No functional change.
2023-07-04 18:42:11 +02:00
Johannes Altmanninger
5678602af4 Stop special input functions "and" & "or" from tearing up multi-char binding
The tentative binding for the upcoming "history-pager-delete" is

    bind -k sdc history-pager-delete or backward-delete-char

When Shift+Delete is pressed while the history pager is active,
"history-pager-delete" succeeds. In this case, the "or" needs to kick the
"backward-delete-char" out of the input queue.
After doing so, it continues reading, but interprets the input as
single-char binding. This breaks when the next key emits a multi-char sequence,
like the arrow keys.

Fix this by reading a full sequence, which means we need to run "read_char()"
instead of "read_ch()" (confusing, right?).

I'm still working on writing a test. Somehow this only reproduces in the
history pager where Shift+Delete followed by down arrow emits "[B" (since
we swallowed the leading escape char).  Confusingly, it doesn't do that in
the commandline or the completion search field.
2023-07-04 18:42:11 +02:00
Fabian Boehm
92551e1818 docs/abbr: Explain saving abbrs 2023-07-04 18:30:28 +02:00
David Adam
472d7efe34 completions/status: add basename and dirname 2023-07-04 23:32:39 +08:00
ridiculousfish
2ec482e94a Move the Option out of ParsedSourceRef, and use Arc instead of Rc
Two small fixes:

1. ParsedSourceRef, if present, should not be None; express that in the type.
2. ParsedSourceRef is intended to be shareable across threads; make it so.
2023-07-02 17:46:04 -07:00
Fabian Boehm
a996c8c7dd Fix clippy
As always: Some petty complaints of no actual use
2023-07-02 10:10:29 +02:00
ridiculousfish
12dfbc14d7 Make builtin status long options const
By using an explicit match instead of unwrap(), we can avoid the use of Lazy.
2023-07-01 16:05:10 -07:00
ridiculousfish
1c5c1993dd Make wdirname and wbasename go &wstr -> &wstr
There is no reason for either of these functions to allocate, so have
them not do it.
2023-07-01 15:41:46 -07:00
ridiculousfish
d26d4f36b0 Minor fixes to builtin status
Use as_wstr() instead of from_ffi() in a few places to avoid an allocation,
and make job_control_t work in &wstr instead of &str to reduce complexity at
the call sites.
2023-07-01 15:33:11 -07:00
Henrik Hørlück Berg
4061c7250c Replace status_cmd with an option
- Using an option makes it much clearer that the check for empty args is
  redundant.
- Also prefer implementing TryFrom only for &str, to not hide the string
  conversion and allocation happening.
2023-07-01 15:33:01 -07:00
Henrik Hørlück Berg
cee2b7c4a2 Remove C++ code 2023-07-01 15:33:01 -07:00
Henrik Hørlück Berg
7b3637cd1f Port builtins/status to fish
- Also port tests of wdirname and wbasename, as they were bugged
2023-07-01 15:33:01 -07:00
ridiculousfish
37337683cb Revert "Fix Rust wdirname and wbasename and port the C++ tests"
This reverts commit 6b1c2e169c.

We're about to rework these in the builtin status changes.
2023-07-01 13:38:38 -07:00
ridiculousfish
6b1c2e169c Fix Rust wdirname and wbasename and port the C++ tests
These functions were rather buggy; add tests and fix the test failures.
2023-07-01 12:45:11 -07:00
ridiculousfish
b4570623e9 Changelog fix for #9863 2023-07-01 11:08:53 -07:00
Francois Laithier
a7ac92f62f Use __fish_complete_directories to help complete dirs only 2023-07-01 11:01:36 -07:00
Francois Laithier
911a5a97a8 Add completion option for curl
Add missing completion for curl's `--output-dir` option
2023-07-01 11:01:36 -07:00
David Adam
ce9f95128a type/command: implement optimisation for --all
This was present in the C++ version for command, though never for type.

Checking over all elements of PATH can be slow on some platforms eg
WSL2, so only do that when used with `--all`.

Based on discussion in
https://github.com/fish-shell/fish-shell/pull/9856
2023-06-30 10:05:01 +08:00
David Adam
14cfd268d8 path: drop path_get_paths_ffi
f77dc24 provides the pieces to call path_get_paths directly from Rust
code. Drop the C++ implementation and its FFI.
2023-06-30 10:05:01 +08:00
Henrik Hørlück Berg
1f67bcbb39 Update dependencies for asan to work
Rust nightly changed the name of a preview feature, which broke proc-macro2,
see https://github.com/rust-lang/rust/issues/113152
2023-06-29 20:02:43 -05:00
Fabian Boehm
9bcb4dcf70 docs: Remove some needless margins for nested lists
This double-indented a nested list *and* added some gaps at the
bottom.

Other lists are unaffected
2023-06-28 16:32:55 +02:00
Fabian Boehm
b043a1c35f completions/help: Add custom-prompt 2023-06-28 16:13:20 +02:00
Fabian Boehm
22f2926185 docs/prompt: Fix nested list formatting
Sphinx needs three spaces here at least
2023-06-28 16:13:00 +02:00
Fabian Boehm
c7b43b3abf Truncate builtin arguments on NUL
This restores the status quo where builtins are like external commands
in that they can't see anything after a 0x00, because that's the c-style
string terminator.
2023-06-24 21:26:44 +02:00
Fabian Boehm
41568eb2a8 Move NUL-handling tests to their own file 2023-06-24 21:26:44 +02:00
David Adam
78940a6026 print_help: make function public 2023-06-24 18:21:21 +08:00
Fabian Boehm
11c8d9684e
Make NULs work for builtins (#9859)
* Make NULs work for builtins

This switches from passing a c-string to output_stream_t::append to
passing a proper string.

That means a builtin that prints a NUL no longer crashes with "thread '' panicked
at 'String contained intermediate NUL character: ".

Instead, it will actually handle the NUL, even as an argument.

That means something like

`echo foo\x00bar` will now actually print a NUL instead of truncating
after the `foo` because we passed c-strings around everywhere.

The former is *necessary* for e.g. `string`, the latter is a change
that on the whole makes dealing with NULs easier, but it is a
behavioral change.

To restore the c-string behavior we would have to truncate arguments
at NUL.

See #9739.

* Use AsRef instead of trait bound
2023-06-22 20:50:22 +02:00
David Adam
a75de42f4b docs: use consistent spelling of color
i miss u
2023-06-21 21:13:03 +08:00
David Adam
229f19a6e9 docs: slight update to writing your own prompt doc 2023-06-21 21:12:12 +08:00
Fabian Boehm
c385027eca
docs: Add "Writing your own prompt" doc (#9841)
* docs: Add "Writing your own prompt" doc

* Remove a space from the "output"

* some teensy adjustments

* Address feedback

* envvar one more PWD

* More html warning
2023-06-20 19:43:09 +02:00
ridiculousfish
f77dc2451e Expose Rust EnvStack from parser_t
Prior to this change, parser_t exposed an environment_t, and Rust had to go
through that. But because we have implemented Environment in Rust, it is
better to just expose the native Environment from parser_t. Make that
change and update call sites.
2023-06-19 13:45:54 -07:00
ridiculousfish
6936c944c1 Add some fixes atop argparse
This switches to using the WExt functions, which deal directly in chars
and char indices.
2023-06-19 13:45:54 -07:00