Commit Graph

17100 Commits

Author SHA1 Message Date
Johannes Altmanninger
a848877e65 Remove an overload in io, to prepare for Rust 2023-04-16 17:21:54 +02:00
Johannes Altmanninger
85ae1861fa common.rs: fix leftover comment 2023-04-16 17:21:54 +02:00
Johannes Altmanninger
df6525e770 Make RustBuiltin a scoped enum
This prevents name clashes. It already is used as scoped enum.
2023-04-16 17:21:54 +02:00
Xiretza
61028f020c cargo update
This fixes an issue with rust-analyzer always rebuilding even without changes,
which was introduced by b8189da011.
2023-04-16 17:21:54 +02:00
Fabian Boehm
bf0ebd3967 Actually add builtin.rs 2023-04-16 11:41:41 +02:00
Fabian Boehm
72a32f1a12 Rewrite "builtin" builtin in Rust
This is very simple and basically a subset of type.
2023-04-16 11:30:31 +02:00
Fabian Boehm
b65a53a2a6 Rewrite "command" builtin in Rust
This is basically a subset of type, so we might as well.

To be clear this is `command -s` and friends, if you do `command grep` that's
handled as a keyword.

One issue here is that we can't get "one path or not" because I don't
know how to translate a maybe_t? Do we need to make it a shared_ptr instead?
2023-04-16 11:27:08 +02:00
Fabian Boehm
662a4740e2 Rewrite the type builtin in rust 2023-04-16 11:27:08 +02:00
Fabian Boehm
7c37b681b2 Expose out_is_redirected to rust 2023-04-16 11:27:08 +02:00
Fabian Boehm
d02d0f3309 highlight: Add colorize_shell wrapper
Since we don't reuse the vector anyway, this allows us to keep the
highlighting on the C++-side.
2023-04-16 11:27:08 +02:00
Fabian Boehm
31d65de26c function: Add a bunch of awkward helper functions
This makes function_properties_ref_t not const, in order to work
around cxx
2023-04-16 11:27:08 +02:00
Fabian Boehm
d0c2d0c9cf path: Add method to return wcstring_list_ffi_t
This is palatable to Cxx
2023-04-16 11:27:08 +02:00
ridiculousfish
15c8f08458 Eliminate to_rust_string_vec
This can just use wcstring_list_ffi_t now.
2023-04-15 18:15:37 -07:00
ridiculousfish
dee969bf3a Introduce wcstring_list_ffi_t
wcstring_list_ffi_t is an autocxx-friendly type for passing lists of
strings from C++ to Rust.
2023-04-15 17:53:52 -07:00
Jan Tojnar
9e223577aa Fix composer require completion
When no development dependencies are installed, the completion would crash with:

    KeyError: 'require-dev'
2023-04-12 21:05:23 +02:00
Paweł Piątkowski
bda9d57417 Ansible completion: fix typo in --limit-hosts 2023-04-12 16:52:13 +02:00
Johannes Altmanninger
9983c32a57 Port over builtin exit codes
They used to live in common.h but they are mostly used by builtins so I
grudgingly accept the early move.
2023-04-11 09:29:28 +02:00
Mahmoud Al-Qudsi
d728b884dd Update pinned cxx dependency
Pulls in fish-shell/cxx 00536f3b771c9741bc325b37e7627d52052240a3 which
implements `VectorElement` for `CxxWString`.
2023-04-10 20:51:07 -05:00
Eric N. Vander Weele
fdd4bcf718 completions/git: Allow switch to complete remote branches
While it is true that `git switch <remote-branch>` errors to disallow a detached
head without the `-d` option, it is valid to use any starting point (commit or
reference) in conjunction with the `-c` option. Additionally, the starting point
can occur before any option.

This enables the following completions:

* `git switch -c <local-name> <any-branch>`
* `git switch <any-branch> -c <local-name>`
* `git switch -d <any-starting-point>`
* `git switch <any-branch> -d`

The trade-off is this does allow for `git switch <remote-branch>` to be
completed with an error.

Note that this logically reverts 7e3d3cc30f.
2023-04-10 17:04:34 +02:00
AsukaMinato
8a0510a2f2 add qjs completion 2023-04-10 11:02:43 +02:00
AsukaMinato
36e4b0ff30
add completion for ar (#9720)
* add completion for ar

* clean the function

* update CHANGELOG
2023-04-10 11:01:47 +02:00
ridiculousfish
de24e84a48 Changelog fix for #9722 2023-04-09 11:34:45 -07:00
abp
bbe2a2ba9b completions: Shortened descriptions
- Mainly work is done on gcc
- Some duplicated removed elsewhere
2023-04-09 11:33:23 -07:00
ridiculousfish
0ad3e3a45d Changelog fix for #9717 2023-04-08 20:23:21 -07:00
Eric N. Vander Weele
4ed53d4e3f reader: Apply fish_color_selection fg color and options in vi visual mode
Vi visual mode selection highlighting behaves unexpectedly when the selection
foreground and background in the highlight spec don't match. The following
unexpected behaviors are:

*  The foreground color is not being applied when defined by the
   `fish_color_selection` variable.
* `set_color` options (e.g., `--bold`) would not be applied under the cursor
  when selection begins in the middle of the command line or when the cursor
  moves forward after visually selecting text backward.

With this change, visual selection respects the foreground color and any
`set_color` options are applied consistently regardless of where visual
selection begins and the position of the cursor during selection.
2023-04-08 20:20:58 -07:00
ridiculousfish
169f90448a Stop generating autoccx ffi wrappers for pcre2 regex
We have "native" FFI wrappers for these now via the pcre2 crate.
2023-04-08 19:05:08 -07:00
Andy Hall
6ff971e4c2 Fix typo in set docs 2023-04-08 18:56:46 -07:00
Eric N. Vander Weele
a6e16a11c2 docs/interactive: Document fish_color_history_current variable
All *.theme files set variables documented in the "Syntax highlighting
variables" section, and fish_color_history_current was missing.
2023-04-07 15:29:23 +02:00
David Adam
733b981983 fish.spec/Debian packaging: add cargo dependency 2023-04-07 12:45:24 +08:00
David Adam
8c645186c0 fish.spec: replace tabs with spaces 2023-04-07 12:22:34 +08:00
ridiculousfish
a487b1ecf2 Revert "Revert "Implement builtin_printf in Rust""
This reverts commit 9f7e6a6cd1.

Add additional fixes from code review.
2023-04-06 15:54:09 -07:00
ridiculousfish
2d6f752f6e Revert "Add link-asan to RUSTFLAGS in CI"
This reverts commit 8bb1bb8ae1.
2023-04-06 14:29:18 -07:00
ridiculousfish
14c5c94d01 Use hexponent to implement hex float parsing in wcstod
This teaches wcstod to parse hex floats like 0x1.5p3 via a forked
version of hexponent. This support is necessary for printf.
2023-04-06 14:29:18 -07:00
ridiculousfish
74104f76ad wcstod() to skip leading whitespace
This matches the C implementation.
2023-04-06 14:29:18 -07:00
Fabian Boehm
79f8364bc7 docs/completions: Add a teensy bit more
This should really be expanded instead of just pointing at the example
2023-04-04 18:07:25 +02:00
Fabian Boehm
a6560a4ea8 docs/fish_add_path: Also clarify the examples 2023-04-04 17:55:10 +02:00
Fabian Boehm
4a39772ed2 docs/fish_add_path: More on --path and appending 2023-04-04 17:50:01 +02:00
Miha Filej
b5bfff9cac
completions/mix: Add options for phx.new in 1.7.2 (#9706) 2023-04-04 07:41:11 -05:00
Marcin Wojnarowski
0f1ef34736
Fix adb path completion (#9707)
Support paths with spaces.
2023-04-03 22:06:15 -05:00
Mahmoud Al-Qudsi
3932ed118e Update cxx dependency
The let_cxx_wstring!() macro now works and can be used to avoid needing an extra
ffi call to obtain a (pinned) wstring object.
2023-04-03 22:03:08 -05:00
David Adam
5a03a17b9a make_tarball: fix the vendor tarball generation path
Tilde expansion doesn't work inside quotes.
2023-04-02 21:20:49 +08:00
Johannes Altmanninger
a3e6353c05 Remove redundant comment, fish targets Unix-like systems 2023-04-02 15:17:06 +02:00
Johannes Altmanninger
ad5c86604b Simplify string narrowing logic 2023-04-02 15:17:06 +02:00
Johannes Altmanninger
735d6a53a5 common.rs: implement string escaping
This is duplicated (but need not be).
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
05bad5eda1 Port common.{h,cpp} to Rust
Most of it is duplicated, hence untested.

Functions like mbrtowc are not exposed by the libc crate, so declare them
ourselves.
Since we don't know the definition of C macros, add two big hacks to make
this work:
1. Replace MB_LEN_MAX and mbstate_t with values (resp types) that should
   be large enough for any implementation.
2. Detect the definition of MB_CUR_MAX in the build script. This requires
   more changes for each new libc. We could also use this approach for 1.

Additionally, this commit brings a small behavior change to
read_unquoted_escape(): we cannot decode surrogate code points like \UDE01
into a Rust char, so use � (\UFFFD, replacement character) instead.
Previously, we added such code points to a wcstring; looks like they were
ignored when printed.
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
998cb7f1cd New wcs2zstring to explicitly convert to zero-terminated strings
wcs2string converts a wide string to a narrow one.  The result is
null-terminated and may also contain interior null-characters.
std::string allows this.

Rust's null-terminated string, CString, does not like interior null-characters.
This means we will need to use Vec<u8> or OsString for the places where we
use interior null-characters.
On the other hand, we want to use CString for places that require a
null-terminator, because other Rust types don't guarantee the null-terminator.

Turns out there is basically no overlap between the two use cases, so make
it two functions. Their equivalents in Rust will have the same name, so
we'll only need to adjust the type when porting.
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
3b15e995e7 str2wcs: encode invalid Unicode characters in the private use area
Rust does not like invalid code points, so let's ease the transition by
treating them like byte sequences that do not map to any code point.
See https://github.com/fish-shell/fish-shell/pull/9688#discussion_r1155089596
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
746019e4ad common.rs: reorder to match C++ companion
This makes it easier to check that we ported everything.
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
ed3a0b2bc3 Move join_strings into wcstringutil.rs
On the C++ side it lives in wcstringutil.cpp.  We should probably keep
it there until we have ported the entirety of that file.
2023-04-02 15:17:06 +02:00
Johannes Altmanninger
4f14b8dc7b Rename byte encoding helper
Existing C++ code didn't use a function for this but simply added
ENCODE_DIRECT_BASE. In Rust that's more verbose because char won't do
arithmetics, hence the function.

We'll add a dual function for decoding, so let's rename this.

BTW we should get rid of the "wchar" naming, it's just "char" in Rust.
2023-04-02 15:17:06 +02:00