Commit Graph

19014 Commits

Author SHA1 Message Date
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
Fabian Boehm
6706b15fbc fish_add_path: Automatically enable verbose mode for interactive use
fish_add_path can be used either interactively, in the commandline,
or in config.fish. That's its greatest strength, it's a very
DWIM-style command.

One of the compromises that entails, however, is that it can't really
be very loud about what it does. If it skips a path, it can't write a
warning because it might be used in config.fish.

But it *can* if it's used interactively. So we try to detect that case
and enable verbose mode automatically.

That means if you do

```fish
fish_add_path /opt/mytool/bin/mytool
```

it may tell you "Skipping path because it is a file instead of a
directory:".

The check isn't perfect, it goes through status current-command and
isatty, but it should be good for most cases (and be false in config.fish).
2024-06-06 16:47:39 +02:00
Fabian Boehm
3411b72a6d Curses: Update the comments 2024-06-04 22:23:46 +02:00
Fabian Boehm
90bd8cc02b Remove errant .rs2 file 2024-06-04 21:55:43 +02:00
tesuji
01e958d2fb
git: add completion for sparse-checkout subcommand (#10542) 2024-06-02 22:02:06 -05:00
Mahmoud Al-Qudsi
9f0e034fad Fix curl data string from path completions
Closes #10539.
2024-06-02 21:58:54 -05:00
Mahmoud Al-Qudsi
d90d924c8c Remove parser library_data_pod_t ffi workaround
We don't need to separate POD fields from the main parser libdata any more.
2024-06-02 20:27:44 -05: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
ridiculousfish
15c0313c33 Fix pexpect_helper.py prompt regex
The prompt regex for pexpect was:

```
    return re.compile(
        r"""(?:\r\n?|^)   # beginning of line
            (?:\x1b[\d[KB(m]*)* # optional colors
            (?:\x1b[\?2004h) # Bracketed paste
            (?:\x1b[>4;1m) # XTerm's modifyOtherKeys
            (?:\x1b[>5u) # CSI u with kitty progressive enhancement
            (?:\x1b=) # set application keypad mode, so the keypad keys send unique codes
            (?:\[.\]\ )?  # optional vi mode prompt
         """
        + (r"prompt\ %d>" % counter)  # prompt with counter
        + r"""
            (?:\x1b[\d\[KB(m]*)* # optional colors
        """,
        re.VERBOSE,
    )
```

This has a terrible bug: an accidentally unescaped bracket here:

    (?:\x1b[>4;1m) # XTerm's modifyOtherKeys
           ^

This bracket then extends throughout the entire regex, and is
accidentally terminated here:

    (?:\x1b[\d\[KB(m]*)* # optional colors
                    ^

Thus the whole regex is busted; in particular the prompt counters are
not being tested correctly.

A second issue is that these escape sequences are not emitted before the
first prompt, so correcting the regex will cause every test to fail.

Fix this by ignoring all of the escape sequences and merely look for
the "prompt %d>" portion.

THIS DELIBERATELY CAUSES TEST FAILURES.

The tests were already broken and falsely reported as passing.
These will be fixed in followup commits.

Good news is that the tests should become way more reliable after
this is fixed - hopefully no more introducing random sleep() calls.
2024-06-02 14:07:35 -07:00
Fabian Boehm
28484e2498 CHANGELOG: Fix issue mention 2024-06-02 10:52:11 +02:00
Fabian Boehm
94644e88fb Revert "Reduce size of Block to 32 bytes"
This doesn't pull its weight. Block size is not a particularly big
problem,
and this both complicates the code a bit and would arbitrarily cause issues
if a fish script exceeded 65k lines.

This reverts commit edd6533a14.
2024-06-02 10:44:15 +02:00
Mahmoud Al-Qudsi
ac40807309 Reduce explicit Block state
This doesn't have any effect on the size of the struct (due to alignment
requirements and padding) but reduces the complexity by turning
Block::wants_pop_env into an emergent property dependent on the type rather than
something we have to manually manage.
2024-06-01 13:16:24 -05:00
Mahmoud Al-Qudsi
2e52d51af2 Convert Block::event_blocks to a bool
We only increment it and check if it's non-zero, we never decrement or check the
actual count. As such, change it to a bool and bring the size of `Block` down
from 32 to 24 bytes.
2024-06-01 13:01:40 -05:00
Mahmoud Al-Qudsi
edd6533a14 Reduce size of Block to 32 bytes
We don't need 16 bytes (plus the `Option` overhead) to store the line number!
2024-06-01 12:49:15 -05:00
Mahmoud Al-Qudsi
5ca76564a4 Store BlockData in a Box
We almost never access any of this and having it stored directly in the `Block`
struct increases its size (reducing how many we can fit in L1 and L2, and
increasing memory copy traffic).

Gets rid of BlockData::None so we can avoid allocating a Box at all when we have
no data (at the cost of yet-another-wrapper-type), which is the usual case.
2024-06-01 11:41:32 -05:00
Mahmoud Al-Qudsi
1d159277c6 Move Block fields specific to certain block types to separate enum
This has a few advantages,
* We now statically assert that all fields used by a particular block type are
  correctly initialized (i.e. you can't assign the function name but forget to
  assign its arguments),
* Conversely, we can match directly on `BlockData` and be guaranteed that the
  fields we want to access are initialized and present,
* We reduce the number of assertions, effectively "unwrapping" only once based
  off the block type instead of each time we try to access a conditional field,
* We reduce the size of the `Block` struct by coalescing fields that cannot
  co-exist, bringing it down from 104 bytes to 88 bytes.

It would be nice to make all of `Block` itself an enum, but it currently
requires `Copy` and we take advantage of that to copy it around everywhere.
Putting these fields directly in `Block` directly would mean a lot more memory
traffic just checking block types.
2024-06-01 11:15:19 -05:00
Mahmoud Al-Qudsi
0246c938ca Coalesce BlockType::function_call and BlockType::function_call_no_shadow
There's no need for two separate block types when one is merely a variant of the
other. This may have been required under C++ but thanks to sum types (rust's
enums) we don't need to do that any more.
2024-05-31 20:53:52 -05:00
Mahmoud Al-Qudsi
fc9a743622 completions/env: overhaul completions
The value completions were rendered almost entirely useless due to the forced
inclusion of file completions at all tokens, including in the head/command
position thanks to the use of `__fish_complete_subcommand` which doesn't
understand the semantics of `env` and expects something like `ssh`. But we don't
need it at all.
2024-05-31 20:49:48 -05:00
Mahmoud Al-Qudsi
6ec09260dd Changelog: document #5263 and provide workaround
[ci skip]
2024-05-31 16:21:24 -05:00
Mahmoud Al-Qudsi
417e89a4b3 Work around WSLv1 not properly cleaning up stopped orphaned jobs
See #5263.
2024-05-30 21:31:04 -05:00
Mahmoud Al-Qudsi
6c944debec Send signals in the correct order in hup_jobs()
If the backgrounded/stopped job was using the tty, sending it SIGCONT first
might cause it to immediately wake and try to use the tty (which fish still has
control over), causing it to immediately stop again after receiving a SIGTTOU.

We are supposed to send SIGHUP first so that when the process resumes it sees
the queued SIGHUP and executes its registered handler!
2024-05-30 18:26:13 -05:00
Mahmoud Al-Qudsi
e1ee193822 Speed up __fish_make_cache_dir
Don't fork/exec an external process, especially one performing IO, if we don't
have to.

This, in turn, speeds up __fish_source_cached_completions which is rather slow
under WSL (and slower than it needs to be on other platforms).
2024-05-30 17:03:03 -05:00
Mahmoud Al-Qudsi
98642d307a Don't use a graphical browser under SSH
...unless X is also being forwarded.

Someone else will have to figure out the Wayland equivalent (if that even
exists). Not my monkey, not my circus.
2024-05-30 16:15:07 -05:00
Mahmoud Al-Qudsi
7d77d7aa84 Convert more block iteration methods to use iterators 2024-05-30 15:54:54 -05:00
Fabian Boehm
0a8fd05bb0 docs/fish_add_path: Reword description
Use "directories" explicitly instead of "components" to make it more
clear that the arguments need to be directories, not files.

Also a bit on intent and variable scope.
2024-05-30 22:52:03 +02:00
Mahmoud Al-Qudsi
f6200224fc Use Iterator::count() to check function stack depth 2024-05-30 12:49:28 -05:00
Mahmoud Al-Qudsi
b495cffa50 fixup! Add workaround for targets with too small a main stack size 2024-05-30 12:25:06 -05: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
57f558578b Add workaround for targets with too small a main stack size
pthread_get_stacksize_np() is buggy on legacy OS X; make sure you are building
fish with a rust toolchain that correctly patches these functions.

See https://github.com/macports/macports-legacy-support/pull/86
2024-05-30 12:14:37 -05:00
Mahmoud Al-Qudsi
46f6aa8024 Update ssh-keygen completions
Don't run `ssh` upon sourcing and don't rely on `ssh -Q` being available.
2024-05-29 14:08:21 -05:00
Mahmoud Al-Qudsi
828b88a212 Add issue reference to flatpak completion workaround
[ci skip]
2024-05-29 13:54:39 -05:00
Mahmoud Al-Qudsi
7bf3b57e47 Fix buggy test_pthread() condvar test
There's no guarantee that a condition variable is stateful. The docs for
`Condvar::notify_one()` actually say the opposite:

> If there is a blocked thread on this condition variable, then it will be woken
> up from its call to wait or wait_timeout. Calls to notify_one are not buffered
> in any way.

This test was relying on the main loop obtaining the lock and entering the
condition variable sleep before the thread was scheduled and got around to
notifying the condition variable. If this non-deterministic behavior was not
upheld, the test would time out since it would obtain the lock (either before or
after the variable were updated) then call `condvar.wait()` *after* the variable
had been updated and the condvar signalled, but without (atomically or even at
all) checking to see if the desired wake precondition was fulfilled. As the
child thread had already run and the wake notification was NOT buffered, there
was nothing to wake the running thread.

There really wasn't any way to salvage the test as originally written, since the
write to `ctx.val` was not in any way linked to the acquire/release of the mutex
so regardless of whether or not the main thread obtained the mutex and checked
the value precondition before calling `condvar.wait()`, the child thread's write
could have happened after the check but before the wait() call. As such, the
test has been rewritten to use `wait_while()` but then also updated to bail in
case of a timeout instead of hanging indefinitely (since neither the `ctest`
runner nor the `cargo test` harness was timing out; `cargo test` would only
report that the test had exceeded 60 seconds but as long as it was not executed
with `cargo test -- -Z --ensure-time` (which is only available under nightly),
the test would not halt.

If this test were *intentionally* written to test the scenario that was timing
out, it should be written deterministically in such a way that the main loop
did not run until after it was guaranteed that the variable had been updated
(i.e. by looping until val became 5 or waiting for an AtomicBool indicating the
update had completed to be set), but I'm not sure what the benefit in that would
be since the docs actually guarantee the opposite behavior (the notified state
is explicitly not cached/buffered).

If we have fish code written with the assumption that condvar notifications
prior to *any* call to `Condvar::wait()` *are* buffered, then that code should
of course be revisited in light of this.
2024-05-29 13:13:13 -05:00
Johannes Altmanninger
390b40e02b Fix regression not refreshing TTY timestamps after external command from binding
Commit 8a7c3ce (Don't abandon line after writing control sequences, 2024-04-06)
was broken by 29f2da8 (Toggle terminal protocols lazily, 2024-05-16), fix that.

Fixes #10529
2024-05-29 12:57:09 +02:00
Mahmoud Al-Qudsi
8c364dc949 CHANGELOG: Fix awkwardly formatted issue reference
The :issue:`xxxx` template generates text in the format (#xxxx), so this was
rendering as "... See (#xxxx)." which is just weird.

[ci skip]
2024-05-28 11:53:36 -05:00
Mahmoud Al-Qudsi
5b7fd61867 Fix single-backtick-quoted code expressions in CHANGELOG.rst
Reminder that reStructuredText is awkward and you can't make sphinx treat these
as inline code; they'll be formatted as italic text only.

Vim search expression:
    \([`:]\)\@<!`[^`:]\+`\(`\)\@!

Followed by
    ysi``

does the trick quite nicely.
2024-05-28 11:47:45 -05:00
Mahmoud Al-Qudsi
8b1c8ed791 CHANGELOG: Add #10506 and #10521 2024-05-28 11:09:09 -05:00
Yuntao Zhao
96416cc49e
feat: improve completion for konsole (#10528)
* feat: improve konsole completion

* Improve konsole profile completion to be dynamic

Directly complete --profile as a long argument

* Dynamically complete konsole -p
2024-05-28 10:26:03 -05:00
Fabian Boehm
f06143c11a docs: Fix some formatting 2024-05-27 23:21:06 +02:00
ridiculousfish
29b620b56c Remove an unused type 2024-05-27 11:45:25 -07:00
ridiculousfish
9e406e4fbc Silence some clippies 2024-05-27 11:07:02 -07:00
Mahmoud Al-Qudsi
6117b5071c Don't ignore assert_sorted_by_name doctest 2024-05-27 10:20:24 -05:00
Fabian Boehm
7850142bef printf/tests: Use c_char instead of i8
Breaks on arm again
2024-05-27 12:47:51 +02:00
Nguyen Huu Kim
8880fa8dd7
feat: add completions for k8s tools (kustomize, flux) (#10473)
* feat: add completions for kustomize

* feat: add completions for FluxCD

* Update flux.fish

* Update kustomize.fish

---------

Co-authored-by: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
2024-05-26 22:12:49 -05:00
Mahmoud Al-Qudsi
f84b1993ec Add path basename -E tests 2024-05-26 22:06:11 -05:00
Mahmoud Al-Qudsi
6091d1149f Document path basename -E 2024-05-26 22:06:11 -05:00