Commit Graph

17636 Commits

Author SHA1 Message Date
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
Henrik Hørlück Berg
292f7b2be1 Port builtins/argparse to Rust 2023-06-19 13:45:54 -07:00
David Adam
6229f08200 rust/print_help: simplify use of OsStrings
See discussion in https://github.com/fish-shell/fish-shell/pull/9818#discussion_r1210829722
2023-06-19 21:57:53 +08:00
Fabian Boehm
0cfdc90551 completions/unzip: Dangit FreeBSD
No "--help" and the man page doesn't mention "-h".
2023-06-18 21:27:29 +02:00
AsukaMinato
bab8fb9517
Add i o for unzip (#9850)
* add -I -O for unzip

* for different distroes.

* avoid grep
2023-06-18 21:04:43 +02:00
ridiculousfish
99c2e476ac Bravely remove writembs macro
The writembs macro was ported from C++, which attempted to detect when a NULL
termcap was used. However we have never gotten a bug report from this. Bravely
remove it.
2023-06-17 16:04:34 -07:00
ridiculousfish
21f08ee9fd Simplify some curses stuff and enforce that caps are nonempty
The outputter code has a lot of checks that string capabilities are non-empty;
just enforce that at the curses layer so we can remove those checks.

Also remove some types and traits, replacing them with simple functions.
2023-06-17 13:52:53 -07:00
ridiculousfish
dec5a64232 Outputter to implement Write
By implementing Write directly, we can remove some local buffers and uses of
Cursor. This both simplifies and optimizes the code.
2023-06-17 12:14:42 -07:00
ridiculousfish
64a40d2410 write_color_escape to stop returning bool
This bool return was always true, so we don't need it.
2023-06-17 12:14:42 -07:00
ridiculousfish
51a971bf16 Remove tparm0
Per code review, we think that tparm does nothing when there are no parameters,
and it is safe to remove it, even though this is a break from C++. This
simplifies some code.
2023-06-17 12:14:42 -07:00
ridiculousfish
a09947cd99 Implement builtin set_color in Rust
This rewrites the set_color builtin in Rust, restoring italics support in
iTerm2.
2023-06-17 12:14:42 -07:00
ridiculousfish
84b24d5615 Adopt the new output.rs
This switches output.cpp from C++ to Rust.
2023-06-17 12:14:42 -07:00
ridiculousfish
8f38e175ce Add from_ffi() to rgb_color_t
This allows converting a C++ rgb_color_t to a Rust RgbColor.
2023-06-17 12:14:42 -07:00
ridiculousfish
8604be9a4f Port (but do not yet adopt) output.cpp to Rust 2023-06-17 12:14:42 -07:00
ridiculousfish
76205e5b55 Port debug_thread_error() to Rust 2023-06-17 12:14:42 -07:00
Fabian Boehm
38ac21ba5e alias: Escape the function name when replacing
Fixes #8720
2023-06-17 07:46:07 +02:00
Fabian Boehm
f980125fb9 docs: More on profiling 2023-06-16 16:22:58 +02:00
Fabian Boehm
bc190ee818 docs: Turn off highlighting correctly in fish_config 2023-06-16 16:17:58 +02:00
Fabian Boehm
4e3b3b3b0a share/config.fish: Quit if job expansion hack errors
This prevents something like `fg %5` to foreground the first job if
there is no fifth.

Fixes #9835
2023-06-10 15:36:36 +02:00
Fabian Boehm
65769bf8c8 history: Allow deleting ranges
This allows giving a range like "5..7".

It works in combination with more (including overlapping) ranges or
single indices.

Fixes #9736
2023-06-10 15:35:40 +02:00
Andre Eckardt
cbf9a3bbbd improved print CSS for fish_config
This commit introduces a fishconfig_print.css that contains special CSS styles that only apply when printing the fishconfig page. This is especially useful when the user wants to print out the key bindings.
2023-06-10 09:47:01 +02:00
Fabian Boehm
516b8da302 Allow disabling focus reporting 2023-06-10 07:25:20 +02:00