Commit Graph

17530 Commits

Author SHA1 Message Date
ridiculousfish
46f9a8bb28 Stop using sprintf in builtin_random 2023-08-19 20:19:54 -07:00
ridiculousfish
e500250775 Minor improvement to get_depth in ast.rs 2023-08-19 20:19:38 -07:00
ridiculousfish
04299cb4c9 Remove RgbColor::description
This was unused; deriving Debug is sufficient.
2023-08-19 20:04:23 -07:00
ridiculousfish
eeecd6517d Remove FileId::dump
Instead just derive Debug. No reason for this to be custom.
2023-08-19 17:45:17 -07:00
ridiculousfish
d2f7a3507b Implement to_wstr() for ParseTokenType and ParseKeyword
This cleans up some messy call sites.
2023-08-19 17:45:10 -07:00
ridiculousfish
cc1e4b998a Remove some dead bridge code
This was obviated after the AST was ported to Rust.
2023-08-19 16:31:42 -07:00
ysthakur
0f19d7118b
Replace more escapes with quotes in man parser (#9961)
* Replace \(aq with "'" in man parser

* Also replace oq, dq, lq, and rq
2023-08-19 17:10:22 +02:00
Roland Fredenhagen
556bee6893
completions/iwctl: Show network details in completion (#9960)
* completions/iwctl: Show network details in completion

* apply review comments
2023-08-19 17:08:54 +02:00
Fabian Boehm
53a5ce52c5 Implement FLOGF formatting
Note: This *requires* an argument after the format string:

```rust
FLOGF!(debug, "foo");
```

won't compile. I think that's okay, because in that case you should
just use FLOG.

An alternative is to make it skip the sprintf.
2023-08-19 16:56:59 +02:00
Fabian Boehm
798d7427f7 Switch broken uses of FLOGF to FLOG
"FLOGF!" is supposed to treat its first argument as a format
string (but doesn't because that part isn't implemented currently).

That means running something like

```rust
FLOGF!(term_support, "curses var", var_name, "=", value);
```

That would rightly just print "curses var", ignoring the other
arguments.

By contrast, FLOG! is the literal "just join these as a string"
version.
2023-08-19 16:56:59 +02:00
Henrik Hørlück Berg
bc29b4aee1 Move edition and MSRV to workspace 2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
cf5b9d1c7e Specify default-members as fish-rust
We generally only want to operate on the fish crate itself (for now), so this
makes the most sense.
2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
c23f419af1 Use the workspace from CMake
- Make CMake use the correct target-path
- Make build.rs use the correct target dir

Workspaces place it in the project root by default, the alternative to making
this change is to add a `.cargo/config.toml` file with

```toml
[build]
target-dir = "fish-rust/target"
```

Which I think is unnecessary, as we likely want to use the new location anyways.
2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
824e76ebe4 Make CI use the workspace, so we format/check all 2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
87df7b9adf Use a cargo workspace
- This allows running `cargo fmt/clippy/test/etc` from root
- Ideally the root should be the fish-rust package instead of being virtual, but
  that requires changed to CMake/Corrosion. This change should instead be
  completely compatible with our existing setup.
- This also means we will only have on `Cargo.lock` for all current and future
  crates.
2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
1fa56972b5 Fix clippy lint in widestring-suffix 2023-08-19 15:18:38 +02:00
Fabian Boehm
2f86b31bd3 docs: More on scopes
Let's start with an example to motivate the rest
2023-08-19 12:26:27 +02:00
Fabian Boehm
566123edc6
Port builtin count to rust (#9963)
* Port builtin count to rust

* Explicitly use wstring
2023-08-18 23:18:52 +02:00
Fabian Boehm
a29aa44183 functions: Fix command name
This was "function", needs to be "function*s*".

It was only an issue in the option parsing because we set cmd there
again instead of passing it. Maybe these should just be file-level constants?
2023-08-18 17:16:44 +02:00
Axlefublr
fd68aca6ea
fix __fish_list_current_token not recognizing ~ as $HOME (#9954)
* fix __fish_list_current_token not recognizing ~ as $HOME

* right. it was supposed to be $HOME. lol.
2023-08-16 22:05:59 +02:00
Fabian Boehm
1166424eeb Replace some uses of __fish_complete_list 2023-08-16 21:58:07 +02:00
Fabian Boehm
ec42c2ecec completions/exif: Remove use of eval 2023-08-16 21:58:07 +02:00
Henrik Hørlück Berg
88da7121af Adopt appendln 2023-08-16 18:37:27 +02:00
Henrik Hørlück Berg
dceefcdaba Add an appenln method to output_stream_t
This is an alternative to the very common pattern of

```rust
streams.err.append(output);
streams.err.append1('\n');
```

Which has negative performance implications, see https://github.com/fish-shell/fish-shell/pull/9229

It takes `Into<WString>` to hopefully avoid allocating anew when the argument is
a WString with leftover capacity
2023-08-16 18:37:27 +02:00
Fabian Boehm
0874dd6a96 pexpects: Fix spurious failure in generic.py
This used expect_re with a regex ending in `.*`, followed by an
`expect_prompt`.

This meant that, depending on the timing, the regex could swallow the
prompt marker, which caused extremely confusing output like

>Testing file pexpects/generic.py:Failed to match pattern: prompt 14
> ...
> OUTPUT      +1.33 ms (Line 70): \rprompt 13>functions\r\nN_, abbr,
> alias, bg, cd, [SNIP], up-or-search, vared, wait\r\n⏎
> \r⏎ \r\rprompt 14>

Yeah - it shows that "prompt 14" was in the output and it can't find
"prompt 14".

I could reproduce the failure locally when running the tests
repeatedly. I got one after 17 attempts and so far haven't been able
to reproduce it with this change applied.
2023-08-15 19:14:33 +02:00
Fabian Boehm
c07136e8d3 docs: Mention fish_cursor_replace
Fixes #9956
2023-08-15 19:11:03 +02:00
Fabian Boehm
1dc65a694d completions/read: Remove long-removed "--mode-name" flag
Disabled in c6093ad782 (in 2.7.0)
2023-08-15 18:34:41 +02:00
Gregory Anders
69ef51f417 Enable PWD reporting for iTerm2 2023-08-14 18:09:12 +02:00
ridiculousfish
d47b2a7e0b Refactor the killring to make it instanced
This improves test isolation.

Also standardize on the name "killring" instead of "kill list" and remove some
dead code.
2023-08-13 13:06:06 -07:00
ridiculousfish
2b25cd1654 Complete the transition of the kill ring and remove kill.cpp
This finishes off the transition of the kill ring from C++ to Rust, and removes
the C++ bits.
2023-08-13 13:06:06 -07:00
Fabian Boehm
995f12219b Use out_is_terminal
This removes some spurious unsafe and some imports.

Note: We don't use it in `test`, because that can be asked to check
arbitrary file descriptors, while this only checks stdout specifically.
2023-08-13 14:17:52 +02:00
Fabian Boehm
5f0df359b8 Remove C++ version of builtin functions
And the C++ reformat_for_screen and event_filter_names as there are no more users.
2023-08-13 14:17:44 +02:00
Fabian Boehm
6489ef5ac0 Rewrite builtin functions in rust 2023-08-13 14:17:44 +02:00
Fabian Boehm
5e78cf8c41 Add io_streams_t::out_is_terminal()
This encapsulates a "is our output going to the terminal" check we do
in a few places - functions, type, set_color, possibly test
2023-08-13 14:17:44 +02:00
Fabian Boehm
b75f901376 Fix reformat_for_screen
This had an infinite loop because it had two checks broken
2023-08-13 14:17:44 +02:00
Fabian Boehm
ee8e790aa7 Fix event::print's header printing
Turns out doing `==` on Enums with values will do a deep comparison,
including the values.

So EventDescription::Signal(SIGTERM) is !=
EventDescription::Signal(SIGWINCH).

That's not what we want here, so this does a bit of a roundabout thing.
2023-08-13 14:17:44 +02:00
Fabian Boehm
4f86f303f5 Make functions for builtin functions public
event filter names, function::set_desc, common::reformat_for_screen

This is the first use for each
2023-08-13 14:17:44 +02:00
99jte
5b136d450f
Include the target of bad redirects in the error (#9947)
Fixes #8877
2023-08-13 14:01:32 +02:00
ridiculousfish
b2ff4d6bc0 Adopt Rust PosixSpawner
This removes the C++ posix_spawner_t, adopting the Rust implementation.
2023-08-12 17:15:21 -07:00
ridiculousfish
245f7db5b3 Port PosixSpawner to Rust
PosixSpawner is our wrapper around posix_spawn.
2023-08-12 16:59:38 -07:00
Roland Fredenhagen
408ab86090
Add iwctl completions (#9932)
* Add iwctl completions

* review-comments

* options
2023-08-10 19:35:27 +02:00
Emily Grace Seville
f9d21cc21d
Add horcrux completion (#9922)
* feat(completions): horcrux

* feat(changelog): mention completion

* fix(completion): condition for -n
2023-08-09 17:30:34 +02:00
Gabriel Górski
21ddfabb8d
Simplify and fix __fish_is_zfs_feature_enabled (#9939)
* Simplify and fix `__fish_is_zfs_feature_enabled`

Previously `__fish_is_zfs_feature_enabled` was doing
`<whitespace>$queried_feature<whitespace>` pattern matching which
was skipping the state part expected in the follow-up checking code.

Passing the dataset/snapshot in a `target` argument is pointless. As
none of the existing code attempts to do this plus it is also a
private function (`__` prefix), rename of the argument and removal
of extra text replacement should not be considered a breaking change.

* Changed the `&& \` into `|| return`

* Run `fish_indent`
2023-08-09 17:28:01 +02:00
Fabian Boehm
27a11ef7fe builtin builtin: Print help if run without an action to do
Fixes #9942
2023-08-09 17:26:07 +02:00
Henrik Hørlück Berg
0844247b43 Prefer os-unix prelude over importing everything separately 2023-08-09 15:00:58 +02:00
Henrik Hørlück Berg
131e249b0c Adopt the builtin prelude 2023-08-09 15:00:58 +02:00
Henrik Hørlück Berg
773bafb7c7 Add a builtin prelude
- Most builtins share a lot of similar imports
2023-08-09 15:00:58 +02:00
Henrik Hørlück Berg
1b018c8bfb Add note to rust devel about the wchar builtin 2023-08-09 15:00:58 +02:00
Henrik Hørlück Berg
fae090ea67 Adopt the wchar prelude 2023-08-09 15:00:58 +02:00
Henrik Hørlück Berg
5d58652394 Add a wchar prelude
- This will hopefully make it easier to always include WExt and ToWString, and
  make using WStr/WString more natural
2023-08-09 15:00:58 +02:00