Commit Graph

1666 Commits

Author SHA1 Message Date
Johannes Altmanninger
5b249dbb41 test_env: remove stale env sanitization
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
These are unused since 983746a69 (fish_vi_cursor: Remove terminal checks,
2024-08-30).
2024-10-21 12:56:55 +02:00
Johannes Altmanninger
2dbaf10c36 Also refresh TTY timestamps after external commands from bindings
Commit ba67d20b7 (Refresh TTY timestamps after nextd/prevd, 2024-10-13)
wasn't quite right because it also needs to fix it for arbitrary commands.

While at it, do this only when needed:
1. It seems to be only relevant for multiline prompts.
   Note that we can wait until after evaluation to check if the prompt is
   multiline, because repaint events go through the queue, see 5ba21cd29
   (Send repaint requests through the input queue again, 2024-04-19).
2. When the binding doesn't execute any external command, we probably don't
   need to fix up whatever the user printed. If they actually wanted to show
   output and print another prompt, they should currently use  "__fish_echo",
   to properly support multiline prompts. Bindings should produce no other
   output. What distinguishes external programs is that they can trigger this
   issue even if they don't  produce any output that remains visible in fish,
   namely by using the terminal's alternate screen.
   Would be nice if we could get rid of __fish_echo; I'm not yet sure how.

Fixes #10800
2024-10-21 12:13:00 +02:00
Johannes Altmanninger
cd541575b4 Fix completion failing on unclosed brace with wildcard
Completion on ": {*," used to work but nowadays our attempt to wildcard-expand
it fails with a syntax error and we do nothing.  This behavior probably only
makes sense for the overflow case, so do that.
2024-10-19 22:04:54 +02:00
Johannes Altmanninger
00875d0f83 Allow builtin source to read from non-regular files
Commit a91bf6d88 (builtin.c: builtin_source now checks that its argument is
a file., 2005-12-16) fixed an infinite loop for commands like "source /"
where the argument is a directory.

It did so by erroring out early unless the filename argument is a regular file.
This is too restrictive; it disallows reading from special files like /dev/null
and fifos.
Today we get a sensible error without this check, so remove it.
2024-10-13 10:44:38 +02:00
Johannes Altmanninger
ba67d20b7c Refresh TTY timestamps after nextd/prevd
This fixes a macOS-specific bug.  See 390b40e02 (Fix regression not refreshing
TTY timestamps after external command from binding, 2024-05-29) and 8a7c3ceec
(Don't abandon line after writing control sequences, 2024-04-06).

Fixes #10779
2024-10-13 08:17:22 +02:00
Johannes Altmanninger
3a02a3bd6c Fix tmux-multiline-prompt test on some systems
The fast input would race with tmux redrawing the screen,
so sometimes the ": 5" is rendered twice.
2024-10-13 08:17:22 +02:00
Johannes Altmanninger
24e7a2ca60 Disable tmux OSC 133 prompt marking test also on cirrus' old alpine
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
tmux -V prints "tmux next-3.4" there.
2024-10-12 21:05:27 +02:00
Johannes Altmanninger
f77153e6c8 Disable tmux OSC 133 prompt marking test for some tmux versions < 3.4
OSC 133 was added to tmux 3.4.

Also fix the test on macOS where we do have 3.5a in CI; for some reason we
get copy_cursor_y=6 there.  I didn't investigate yet but at least that's
not the same bug this test was made to fix.
2024-10-12 19:48:26 +02:00
Johannes Altmanninger
5496247344 Avoid erasing OSC 133 prompt start marker with clr_eol
For multi-line prompts, we start each leading line with a clr_eol.  Immediately
before printing these prompt lines we emit the OSC 133 prompt start marker.
Some terminals such as tmux interpret make clr_eol delete such markers,
hence prompt navigation is broken.

Fix this by printing the marker only after clr_eol.

The scenario where this triggers is quite odd.  I haven't looked into why
the problem doesn't exist if I remove the recursive repaint request.

See https://github.com/tmux/tmux/issues/4183
Closes #10776
2024-10-12 19:00:16 +02:00
Fabian Boehm
5e8adb18f4 complete: Sort --keep-order completions smaller
This should make the sort have a strict weak ordering, which rust
requires since 1.81 (or it will panic).

Note: This changes the order, but that's *fine* since the current
order is random weirdness anyway.

Fixes #10763
2024-10-05 13:53:02 +02:00
Fabian Boehm
cdcf460edf math: Nicer error for non-ascii-lowercase identifiers
This gave a weird error when you did e.g. `math Foo / 6`:

"Missing Operator" and only the "F" marked.

Adding an operator here anywhere won't help, so calling this an
"Unknown function" is closer to the truth. We also get nicer markings
because we know the extent of the identifier.
2024-09-18 22:27:00 +02:00
Fabian Boehm
e27f4a3744 fish_indent: Truncate file to the size of the text
This can happen in case the formatted script is shorter, e.g. because
we ditched superfluous quotes.

Fixes #10724
2024-09-16 21:08:53 +02:00
Johannes Altmanninger
5ad7ab7b01 Clear some env variables in test env setup 2024-09-14 07:21:18 +02:00
Johannes Altmanninger
5918bca1eb Make "complete -e" prevent completion autoloading
We do the same for functions.

Closes #6716
2024-08-24 08:30:52 +02:00
Fabian Boehm
a4cc9c6975 Skip cd-without-read tests on NetBSD 2024-08-15 17:38:04 +02:00
Fabian Boehm
357eb3cd32 fish_key_reader: use char_to_symbol for verbose output
byte_to_symbol was broken because it didn't iterate by byte, it
iterated by rust-char, which is a codepoint.

So it failed for everything outside of ascii and, because of a
mistaken bound, ascii chars from 0x21 to 0x2F ("!" to "/" - all the punctuation).

char_to_symbol will print printable codepoints as-is and
others escaped. This is okay - something like `decoded from: +` or
`decoded from: ö` is entirely understandable, there is no need to tell
you that "ö" is \xc3\xb6.

This reverts commit 423e5f6c03.
2024-08-13 16:03:47 +02:00
Fabian Boehm
9903eb4c76 Convert ASCII DEL to \x7f
Annoying when you press backspace in fish_key_reader
2024-08-11 14:57:04 +02:00
Fabian Boehm
bd5f9babd7 __fish_seen_subcommand_from: Fix error when there's no second token
Regression from 2bfa7db7bc

Can be triggered e.g. with `complete -C"history "`.
2024-08-08 21:20:07 +02:00
Johannes Altmanninger
3984725b80 Fix tmux-complete test for old tmux versions
The CentOS Stream image I used provided tmux 2.7 which doesn't know about the
"Delete" alias.
2024-08-05 10:41:17 +02:00
Johannes Altmanninger
615b413335 Mention in changelog that universal notifiers are not yet supported on BSD 2024-08-05 10:41:17 +02:00
Xiretza
fd006e02da Fix cd .. to the root directory
The leading slash always needs to be present, even if there aren't any other
components. This was introduced by the Rust port.
2024-07-29 10:23:29 -07:00
Johannes Altmanninger
c3cf3792f3 Expand tilde after brace expansion
Fixes #10610
2024-07-23 11:47:58 +02:00
Mahmoud Al-Qudsi
fe63775ec5 string: Also escape new lines with --style=regex
This isn't *required* in the PCRE2 spec but it greatly increases the utility of
escaped regex strings at the commandline.
2024-07-16 17:05:11 -05:00
Mahmoud Al-Qudsi
936f7d9b8d Add pexpect test for commandline --showing-suggestion 2024-07-07 22:34:36 -05:00
Mahmoud Al-Qudsi
8b7597913e Add tests for string match/replace --max-matches 2024-06-30 17:51:50 -05:00
Mahmoud Al-Qudsi
b5f5fa98bf Fix __fish_describe_command integration test under macOS
__fish_apropos is a huge hack under macOS and it seems that it's either broken
or man pages are missing/not indexed under CI. In all cases, hard-code the
results of __fish_describe_command to test the integration machinery
specifically and get the test to pass under macOS CI.
2024-06-27 21:35:06 -05:00
Mahmoud Al-Qudsi
dd7d537d90 Add regression test for command completion descriptions 2024-06-27 20:45:38 -05:00
Looouiiis
480d48351c feat(math): add round options (#9117)
Add round options, but I think can also add floor, ceiling, etc. And
the default mode is trunc.

Closes #9117

Co-authored-by: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2024-06-23 17:45:52 -05:00
Mahmoud Al-Qudsi
7d1942a023 Add reduced-accuracy variants of some math tests under x86
Due to the inherent floating point accuracy issues under i586 described
in #10474 and at https://github.com/rust-lang/rust/issues/114479, we need to add
a workaround to our littlecheck math tests to perform less stringent comparisons
when fish was built for x86 without SSE2 support.

This commit addresses the littlecheck issues that caused #10474 to be re-opened,
but I still have to reproduce the cargo test failures for
`negative_precision_width`, `test_float`, `test_float_g`, and `test_locale`.
2024-06-23 16:14:02 -05:00
Fabian Boehm
04da7043a6 tests: Remove skipped tests hack for Cmake < 3.9.0
We require 3.19

This also makes skipped tests visible, which showed that the
print-help test was never run because the REQUIRES line was off.

In sh-mode, bash's `command -v` returns true if *all* commands exist.
2024-06-11 16:55:11 +02:00
Fabian Boehm
652996124d reader: Remove a panic
The special input functions self-insert, self-insert-not-first, and
and or used to be handled by inputter_t::readch, but they aren't
anymore with `commandline -f`.

I am unsure if these *would* have worked, I can't come up with a use.

So, for now, do nothing instead of panicking.
2024-06-10 17:14:13 +02:00
Fabian Boehm
c7d878a8d2 input: Let function_pop_arg return an Option
This would crash if you ran `commandline -f backward-jump`.

The C++ version would read a char (but badly), this doesn't anymore.

So, at least instead of crashing, just do nothing.
2024-06-10 17:02:11 +02:00
Fabian Boehm
f59cdfaa8d fish_add_path: Be more informative in verbose mode
One issue with fish_add_path at the moment is that it is sometimes a bit too intransparent.

You'll try to add a path, but it won't appear - was that because it wasn't a directory,
or because it doesn't exist, or because it was already included?

If it isn't usable after, did fish_add_path not add it because of something or did something *else* remove it?

So we give more explanations - "skipping this because it's a file", "not setting anything because no paths are left to add", ...
2024-06-06 16:47:39 +02:00
ridiculousfish
abf92fcbd1 Fix the bind.py tests
Errant newlines were causing extra prompts.
2024-06-02 15:47:15 -07:00
ridiculousfish
c0766c1844 Fix the histfile.py test
Add missing expect_prompt()
2024-06-02 15:31:19 -07:00
ridiculousfish
cb62ed3e3d Bravely reenable fg.py in CI for Mac 2024-06-02 15:11:51 -07:00
ridiculousfish
96faad247f Fix the fg.py pexpect test 2024-06-02 15:07:23 -07:00
ridiculousfish
25ac5bdb49 Fix the undo pexpect
Add the missing expect_prompts to reflect where we send newlines.
2024-06-02 14:17:36 -07:00
Mahmoud Al-Qudsi
a3e0d64e88 Remove usage of env -u
`env -u` is not supported on all platforms we support (e.g. macOS/OS X 10.10).
We don't need these variables erased, blanked works just fine.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
4b840075f4 Patch cd.fish test to support older macOS versions
The sysctl kern.osproductversion is not available on the oldest versions
we support.
2024-05-30 12:14:43 -05:00
Mahmoud Al-Qudsi
f84b1993ec Add path basename -E tests 2024-05-26 22:06:11 -05:00
Fabian Boehm
2c3894993f Remove errant profiling enabling
This enabled the profile in fish_setlocale, which caused startup
profile to always be on, so

```fish
fish --profile file -c 'foo'
```

would show the entire startup as well
2024-05-26 10:32:28 +02:00
Fabian Boehm
d5101e1923 set: Put back zero-index error instead of crashing
This was missed in the initial port in 77aeb6a2a8.
2024-05-25 21:32:40 +02:00
Fabian Boehm
bf9e5583ba Push and pop for-block every run through the loop
We do the same in while loops. This clears the local variables every time.

Fixes #10525
2024-05-25 13:20:05 +02:00
Johannes Altmanninger
2fa98ec20c Fix deadlock when importing universal LC_* variable
The C++ version of this code simply copied the entire uvar table.
Today we take a reference. It's not clear which one is better.

Removal of locale variables like LC_ALL triggers variable change handlers
which call EnvStackImpl::get. This deadlocks because we still hold the lock
to protect the reference to all uvars.  Work around this.

Closes #10513
2024-05-21 23:11:06 +02:00
Johannes Altmanninger
d40d2b786f Work around wants_terminal not begin set inside eval
On this binding we fail to disable CSI u

    bind c-t '
        begin
            set -lx FZF_DEFAULT_OPTS --height 40% --bind=ctrl-z:ignore
            eval fzf | while read -l r; echo read $r; end
        end
    '

because for "fzf", ParseExecutionContext::setup_group() returns early with the
parent process group (which should be fish's own) , hence "wants_terminal"
is false. This seems questionable, I don't think the eval should make a
difference here.

For now, don't touch it; use the more accurate way of detecting whether
a process may read keyboard input. In many of such cases "wants_terminal"
is false, like

    echo (echo 1\n2\n3 | fzf)

Fixes #10504
2024-05-18 20:55:06 +02:00
Johannes Altmanninger
29f2da8d18 Toggle terminal protocols lazily
Closes #10494
2024-05-16 12:26:47 +02:00
Fabian Boehm
f1e19884fb Add set --no-event
This allows running `set` without triggering any event handlers.

That is useful, for example, if you want to set a variable in an event
handler for that variable - we could do it, for example, in the
fish_user_path or fish_key_bindings handlers.

This is something the `block` builtin was supposed to be for, but it
never really worked because it only allows suppressing the event for
the duration, they would fire later. See #9030.

Because it is possible to abuse this, we only have a long-option so
that people see what is up.
2024-05-14 17:31:47 +02:00
Johannes Altmanninger
a19ff4989a Prevent out-of-order execution following repaint
Commit a583fe723 ("commandline -f foo" to skip queue and execute immediately,
2024-04-08) fixed the execution order of some bindings but was partially
backed out in 5ba21cd29 (Send repaint requests through the input queue again,
2024-04-19) because repainting outside toplevel yields surprising results
(wrong $status etc).

Transient prompts wants to first repaint and then execute some more readline
commands, all within a single binding.  This was broken by the second commit
because that one defers the repaint until after the binding has finished.

Work around this problem by deferring input events again while a readline
event was queued. This is closest to the historical behavior.

The implementation feels hacky; we might find odd situations.
For example,

    commandline -f repaint end-of-line
    set token (commandline -t)

sets the wrong token.
Probably not a very important case. We could throw an error or make it work
by letting "commandline -t" drain the input queue.

That seems too complicated, better change repaints to not use the input queue
(and fake $status etc). Let's try to do that in future.

Closes #10492
2024-05-13 10:44:12 +02:00
ridiculousfish
32ba8d93af Disable cd-without-permission test on macOS < 12
This allows the tests to pass on older macOS, before O_SEARCH was introduced.
2024-05-11 13:20:34 -07:00