Commit Graph

17431 Commits

Author SHA1 Message Date
David Adam
44cf0e5043 add comment regarding importance of unused describe_char function 2023-07-14 20:48:56 +08:00
David Adam
0037e6e98d drop ported C++ functions
Remove the following C++ functions/methods, which have all been ported to Rust and no longer have any callers in C++:
common.cpp:
- assert_is_locked/ASSERT_IS_LOCKED

path.cpp:
- path_make_canonical

wutil.cpp:
- wreadlink
- fish_iswgraph
- file_id_t::older_than
2023-07-14 20:48:56 +08:00
Fabian Boehm
493cbeb84c completions/git: Trim with the regex
This gives us another few percent.

It's not *technically* the same because `trim` would remove a run of
quotes, but that would be wrong anyway.
2023-07-13 18:05:55 +02:00
Fabian Boehm
dd26611c0f completions/git: Move some variables to the v1 path
No longer used elsewhere
2023-07-13 16:51:16 +02:00
Fabian Boehm
7f76f75966 completions/git: Add fast path for untracked files
It's super easy to get a lot of these and they'll otherwise slow down
the completions a lot.

This makes `git add <TAB>` ~5-6x faster with about 4000 untracked
files (a copy of the fish build directory). It goes from 1.5 seconds to
250ms.

This is just for the git >= 2.11 path, but the other one would require
more checking and since git 2.11 is almost 7 years old now that's not
worth it.
2023-07-13 16:46:22 +02:00
Fabian Boehm
1f1975689e completions/git: Don't check commandline so much
This just caches some checks, speeding up `git add ` completions by
~33% with 4000 matching files.
2023-07-13 16:31:33 +02:00
Fabian Boehm
a6c36a014c Return a falsey status if the last -c command has a parse error
This makes `fish -c begin` fail with a status of 127 - it already
printed a syntax error so that was weird. (127 was the status for
syntax errors when piping to fish, so we stay consistent with that)

We allow multiple `-c` commands, and this will return the regular
status if the last `-c` succeeded.

This is fundamentally an extremely weird situation but this is the
simple targeted fix - we did nothing, unsuccessfully, so we should
fail.

Things to consider in future:

1. Return something better than 127 - that's the status for "unknown
command"!
2. Fail after a `-c` failed, potentially even checking all of them
before executing the first?

Fixes #9888
2023-07-12 18:06:34 +02:00
Henrik Hørlück Berg
63b23713f2 Support thread-safe feature-flag-dependant tests
This also allows scoped feature tests that makes testing feature flags thread-safe.
As in you can guarantee that the test actually has the correct feature flag
value, regardless of which other tests are running in parallell.
2023-07-11 12:05:38 -07:00
Henrik Hørlück Berg
f1cd43d58b Disallow using set outside of tests, minor fixes 2023-07-11 12:05:38 -07:00
Henrik Hørlück Berg
726819e8ee Clean up feature flags API
This also cleans up and removes unnecessary usage of FFI-oriented `feature_metadata_t`,
which is only used from Rust code after `builtins/status` was ported.
2023-07-11 12:05:38 -07:00
Fabian Boehm
2b0e3ba3b8 __fish_print_hostnames: Fix regex
This used `]` when it should have been `}`, which made the regex nonsensical

Broken since 94c12d84e2 in 2016
2023-07-11 20:50:56 +02:00
Fabian Boehm
1a11cee559 functions/cd: Optimize check for too many args
This ran two `test`s a `count` and one `echo`, which is a bit wasteful.

So instead, for the common case where you pass one argument, this will
run one `set -q`.

This can save off ~160 microseconds for each ordinary `cd`, which
speeds it up by a factor of ~2 (so 1000 runs of cd might take 260ms
instead of 550ms).

Ideally the cd function would just be incorporated into the builtin,
but that's a bigger change.
2023-07-11 18:01:29 +02:00
elyashiv
3fbff14e9b [tests] added test for escaped job summary 2023-07-10 18:38:26 +02:00
elyashiv
4a2c7e38d0 [jobs.cpp] added const to escaped cmd string 2023-07-10 18:38:26 +02:00
elyashiv
0dfef25b4c [CHANGELOG.rst] added line about escaping jobs 2023-07-10 18:38:26 +02:00
elyashiv
4ea867bc55 [jobs.cpp] add escaping for job comamnd 2023-07-10 18:38:26 +02:00
Adam J. Stewart
72de1dc201 Docs: fix code block 2023-07-10 18:31:46 +02:00
ridiculousfish
57afaf7fb2 Restore the behavior of remembering the CWD fd in the parser
This will be important for concurrent execution, because different parsers will
have different working directories.
2023-07-10 21:30:37 +08:00
David Adam
289fbecaa9 Rewrite cd builtin in Rust
Note this is slightly incomplete - the FD is not moved into the parser, and so
will be freed at the end of each directory change. The FD saved in the parser is
never actually used in existing code, so this doesn't break anything, but will
need to be corrected once the parser is ported.
2023-07-10 21:30:37 +08:00
Adam J. Stewart
e31c0ebb05 Fix grammar in completion docs 2023-07-09 14:11:01 +08:00
ridiculousfish
c1e1efd747 Pull an allocation out of the string escape test inner loop 2023-07-08 11:26:32 -07:00
ridiculousfish
98d88e06ff Use setlocale() in the test_convert test
This "fixes" (or at least hides) the intermittent test_convert failures,
as we no longer race with other setlocale calls.
2023-07-08 11:22:47 -07:00
ridiculousfish
a99fa201b6 Make escape_test an ordinary function
This did not need to be a macro.
2023-07-08 11:19:44 -07:00
Henrik Hørlück Berg
7b0f9fd5f8 Double the speed of cargo test, actually run test
- Parallelize the slow tests if possible.
- `test_convert_ascii` was missing a `#[test]` annotation
2023-07-08 11:05:55 -07:00
Henrik Hørlück Berg
47f1dbe56c Make test_convert seedable, but generate the seed 2023-07-08 11:05:55 -07:00
pd
ac2810e9ef Fix rclone autocompletion script sourcing issue in fish shell 2023-07-07 21:34:12 +02:00
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