Commit graph

627 commits

Author SHA1 Message Date
ridiculousfish
1914c3a513 Clean up wgettext
Because wgettext stores strings forever, we can simply leak them onto the heap;
this cleans up some call sites and type signatures.
2024-01-07 15:51:02 -08:00
ridiculousfish
9aa5a97530 Migrate truncate_at_nul to common and write some tests
This encapsulates a common pattern of truncating a wstr at its first NUL
character.
2024-01-07 15:41:36 -08:00
Johannes Altmanninger
29bd6eebd0 Remove cxx and autocxx
Notably this gets rid of the Cargo target directory inside build directories,
in favor of "target/" at workspace root.
2024-01-07 22:19:56 +01:00
Johannes Altmanninger
bb2a012c7b Use _PATH_BSHELL again in posix_spawn ENOEXEC fallback 2024-01-07 22:19:56 +01:00
Johannes Altmanninger
f7c9753c4b Rename compat.rs to libc.rs
Matches Rust convention better.
2024-01-07 22:19:56 +01:00
ridiculousfish
e110d4c672 Remove some unnecessary L! 2024-01-07 12:36:50 -08:00
Fabian Boehm
0d6c6b2c8a Check MB_CUR_MAX() outside of loop
This is more correct - we don't want to change how we encode this
string in the middle of encoding it, and also happens to be a bit
faster in my benchmarks because this is actually a function call
according to valgrind.
2024-01-07 20:48:47 +01:00
Johannes Altmanninger
8d2fa4ae95 fish_indent: fix accidentally quadratic perf regression due to chars().last()
Iterator::last() consumes the entire iterator, even for DoubleEndedIterator,
see https://github.com/rust-lang/rust/pull/28125#issuecomment-145070161

Because of this, "at_line_start()" took 90% of

    fish_indent share/completions/git.fish

making it take 1000ms instead of 30 ms. Fix that.
2024-01-07 19:04:54 +01:00
Fabian Boehm
53f7d1aa11 Remove ffi_init 2024-01-07 14:37:35 +01:00
Johannes Altmanninger
102ab2c90d Remove FFI code and C++ files
There's a lot more to remove, like
- cxx/autocxx
- now-unused CMake code
- C++ pcre
- C++ entry points
- remaining mentions of "ffi"
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
77550a2f0d Turn FFI tests into native Rust tests
Keep running tests serially to avoid breaking assumptions.

I think many of these tests can run in parallel and/or don't need test_init().
Use the safe variant everywhere, to get it done faster.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
ae9e7a25f8 Port unit test initialization routine
Here are the differences to the C++ version in fish_tests:
1. we don't need to chdir to repo root, cargo test already does.
2. we don't need srandom because we already use deterministic RNGs for tests.
3. we don't yet call asan_before_exit(). Not yet sure how to hook into
  "cargo test" before exit.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
b2d4619125 Link against curses in build.rs too
This will allow to use "cargo test" for unit tests that depend on our
curses.rs.

This means that Rust.cmake depends on ConfigureChecks, so move that one to
the front.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
2f13279423 Remove obsolete tests 2024-01-07 12:12:09 +01:00
Johannes Altmanninger
1b7d4f3b90 Fix latent crash in test_wwrite_to_fd
For whatever reason this did not crash until we made it a proper Rust
unit test.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
3e3441429a Port wgettext wrapper from wutil.cpp
This introduces a string allocations on lookups of strings that are not
known at compile time; we should get rid of these allocations in future.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
cd19f00531 Port setenv_lock/unsetenv_lock 2024-01-07 12:12:09 +01:00
Johannes Altmanninger
d1e3de7c8a Remove some obsolete C++ FFI calls 2024-01-07 12:12:09 +01:00
Johannes Altmanninger
5d299d21a1 Remove some obsolete bridged C++ functions
Most of these were doubled and the C++ variant is obsolete.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
c758765503 Port shell_modes
The C++ one is still there but it's only used in dead code.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
6a64ba6638 Fix build on alpine
musl libc::pthread_t is a pointer so we need to tell Rust it's safe to send
across threads.

Fixes #10195
2024-01-07 02:46:41 +01:00
Johannes Altmanninger
7f110ed4c0 Port fish_key_reader 2024-01-07 00:54:22 +01:00
ridiculousfish
90fde1a9cd Snapshot env when adding to history
[ja: this seems a little bit safer?]
2024-01-07 00:54:22 +01:00
Johannes Altmanninger
55fd43d86c Port reader 2024-01-07 00:54:22 +01:00
Johannes Altmanninger
d8ac0508f8 Stop requiring Send from debounce completion callbacks
Today, debounce-style work items are only created from the main thread.
The work to compute the result is done in a background thread but the
completion callback is called on the main thread again.

The completion callbacks used by the reader capture a shared reference to
ReaderData, which includes a Parser.  Neither of those types needs to be
sent across threads.

The debounce machinery moves the completion callback into a function object
that is moved to the background thread and back again.  Because of this
there is a Send requirement on the completion callback.

Since we already synchronize on MAIN_THREAD_QUEUE, we don't need Send from
the function object. Lift the requirement.
2024-01-07 00:54:22 +01:00
Fabian Boehm
06de374ffd Log original exit code used when a builtin returns a negative exit code
Port of b91723dab6
2024-01-05 16:52:18 +01:00
Fabian Boehm
3213883510 Add error messages where the errors are generated
This removes an awkward hack from ParseError::describe_with_prefix,
where it added errors for two error codes.

andor_in_pipeline was already there, so we just need bare_variable_assignment.
2024-01-04 18:07:40 +01:00
David Adam
365027d55d drop obsolete headers 2024-01-02 01:59:02 +08:00
David Adam
118dfe776a drop unused path functions 2024-01-02 01:59:02 +08:00
Johannes Altmanninger
d8feb0bcd1 builtin bind: remove unused parameter
This file uses the questionable "self.somemethod(self.somefield)" pattern.
We should either set the functions free or stop passing redundant parameters.
Not sure.

For now fix one of them to avoid a string clone.
2024-01-01 18:40:34 +01:00
Johannes Altmanninger
971359876d Work in clippy lint 2024-01-01 18:40:34 +01:00
Johannes Altmanninger
69881f4251
Merge pull request #10180 from ridiculousfish/riir-input
Rewrite input machinery in Rust
2024-01-01 18:38:32 +01:00
Fabian Boehm
6618ca17f2 set: Fix set -e without arguments
This didn't actually error out because we passed all of args.

It *might* be cleaner to pass a slice?
2024-01-01 16:21:08 +01:00
ridiculousfish
8190e3419d Add remaining input FFI bits and port builtin_bind
This implements input and input_common FFI pieces in input_ffi.rs, and
simultaneously ports bind.rs. This was done as a single commit because
builtin_bind would have required a substantial amount of work to use the input
ffi.
2023-12-31 17:17:43 -08:00
ridiculousfish
7ffb62d1d9 Port input.cpp to input.rs
This is not yet adopted.
2023-12-31 15:45:08 -08:00
ridiculousfish
01b04c802e Port input_common.cpp to input_common.rs 2023-12-31 15:45:08 -08:00
ridiculousfish
55054a4bae Add keys to our curses Term structure
This will support rewriting the input machinery in Rust.

Note that while there are a lot of keys here, in practice this is very fast -
taking on the order of microseconds to populate.
2023-12-31 15:44:50 -08:00
Johannes Altmanninger
efa37b6a2e Add back poll of change signaller after adding starting fd monitor
This was missed in ce559bc20 (Port fd_monitor (and its needed components),
2023-02-17).

Fixes the wrong color in

    echo (set_color yellow; date +%T; set_color blue)

as reported in https://github.com/fish-shell/fish-shell/issues/10176#issuecomment-1872658589
2023-12-31 11:07:18 +01:00
Johannes Altmanninger
7d10a72bb3 builtin read: enable bracketed paste
We run __fish_enable_bracketed_paste on every shell prompt, and inside
edit_command_buffer. This protects from accidents when pasting control
characters, and makes sure the paste results in a single undo group.

Let's do the same for builtin read.

Found while doing the research for #10101
2023-12-30 16:58:24 +01:00
ridiculousfish
7bd8328243 Fix some clippy lints 2023-12-29 12:17:22 -08:00
Shou Ya
182a42becc fix typo 2023-12-29 14:54:51 +01:00
ridiculousfish
2a46b24526 Remove some unnecessary imports and suppress unused import warnings 2023-12-28 22:11:50 -08:00
Fabian Boehm
e318585021 Don't replace tilde for error messages if we have no $HOME
This was an issue with "--no-execute", which has no variables and
therefore no $HOME:

```fish
fish --no-execute /path/to/file
```

would say the error is in `~/path/to/file`.

Instead, since this is just for a message, we simply return the
filename without doing the replacement.

Fixes #10171
2023-12-28 10:19:48 +01:00
Shou Ya
31d157f117 Disable redundant filtering in history pager
Part of #10143
2023-12-24 08:42:20 +01:00
Johannes Altmanninger
2358d4dec8 Fix MoveWordStyle naming convention 2023-12-24 08:42:20 +01:00
Johannes Altmanninger
e194f35a5e Port test_word_motion 2023-12-22 18:10:29 +01:00
Johannes Altmanninger
afe9013b4c Port test_pthread 2023-12-22 18:10:29 +01:00
Johannes Altmanninger
daf96a35b5 Fix regression treating read -P as -p
Fixes #10161
2023-12-19 08:24:50 +01:00
Johannes Altmanninger
6446289f41 abbrs: fix naming convention 2023-12-17 17:12:13 +01:00
Fabian Boehm
2be36fbfb6 Use c_char instead of a fixed i8
Char signedness sucks sooooo bad.

Anyway, this broke the build on aarch64 linux.
2023-12-10 17:04:01 +01:00