Commit Graph

19483 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
cdeb3977c3 Re-enable tmux-prompt test under FreeBSD
It passes now that we have uvar notifications working under BSD.
2024-11-14 13:44:49 -06:00
Mahmoud Al-Qudsi
fea1e3aee5 Use iterators to clean up disown logic 2024-11-14 13:25:25 -06:00
Mahmoud Al-Qudsi
c1acbf2845 Deduplicate jobs passed to disown builtin
I'm guessing this was missed in the port because there were comments referencing
using a hash set to perform the deduplication but there was no hashset. (The
TODO was added later.)
2024-11-14 13:24:55 -06:00
Fabian Boehm
366c1b7210 Refuse to search history pager if no new results exist
This prevents searching further and collapsing results into one.

Now I need to figure out how to get it to flash.
2024-11-14 20:02:49 +01:00
Mahmoud Al-Qudsi
4061ef7137 Remove unnecessary Pid::get() calls 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
fc47d9fa1d Use strongly typed Pid for job control 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
2cf4b12d41 Use strongly typed Option<Pid> for event handler
This caught an incorrect description for process/job exit handlers for ANY_PID
(now removed) which has been replaced with a message stating the handler is for
any process exit event.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
95ac51101e Use Option<Pid> instead of Option<pid_t>
Statically assert that the interior value is both positive and non-zero.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
3307672998 Use type safety for pid values
The previous approach of "treat this field as an `Option<NonZeroU32>` and
remember to check `p.has_pid()` before accessing it" was a mix of C++ and rust
conventions and led to some bugs or incorrect behaviors.

* `jobs -p` would previously print both the (correct) external pid and the
  (incorrect) internal value of `0` if a backgrounded command contained a
  fish function (e.g. `function foo; end; cat | foo &; jobs`)
* Updating/calculating job cpu time and usage was incorrectly including all of
  fish's cpu usage/time for each function/builtin member of the job pipeline.

Closes #10832
2024-11-14 13:02:03 -06:00
Fabian Boehm
080e40aac0 Fix crash in history pager
ctrl-r ctrl-s ctrl-s

Attemps to go before the beginning and asserts out. Instead refuse to
do that.

(there's some weirdness where it can reduce the pager to the first
entry if you keep pressing, which I haven't found yet, but that's better than *crashing*)
2024-11-14 16:36:40 +01:00
Fabian Boehm
7846a232a9 cmake: Add some new version gunk
CMake Warning (dev) at cmake/Tests.cmake:56 (add_custom_command):
  Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.  Assuming
  POST_BUILD to preserve backward compatibility.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

So we just keep it the same.
2024-11-13 17:48:15 +01:00
Fabian Boehm
6d76b938c7 bind: Remove "c-" and "a-" shortcut notation
These are another way to spell the same thing that doesn't match what
`bind` would print.

They're also not documented and tested thoroughly.

Since they are just small shortcuts and unreleased we can just remove
them.

Fixes #10845
2024-11-13 17:48:15 +01:00
Mahmoud Al-Qudsi
14a5c0ca44 Disable tmux-multiline-prompt under macOS CI 2024-11-12 17:13:18 -06:00
Mahmoud Al-Qudsi
bb57f2391f Fix a bad comment and clarify delta behavior
s/fish/delta/ and provide a better explanation.
2024-11-12 09:59:10 -06:00
Mahmoud Al-Qudsi
d33cbfd1a3 Prevent delta completions from complain with old version 2024-11-11 16:51:27 -06:00
Mahmoud Al-Qudsi
4e3dc51bc4 Prevent test suite from hanging on panic 2024-11-11 16:45:13 -06:00
Fabian Boehm
960415db3f function: Error out for read-only variables
This will refuse to define the function instead of defining it with an
unusable argument.

Fixes #10842
2024-11-11 17:56:57 +01:00
Fabian Boehm
0ef811c86e dir_iter: Remove duplicate NUL-removal
This goes over the d_name twice.

Filenames already cannot contain NUL (the C-api cannot express it!), so we don't need to scan them.
2024-11-11 17:56:57 +01:00
Mahmoud Al-Qudsi
f0a3a5708f git: complete git diff src/ to show modified files before unmodified ones
This has the side effect of changing the order of completions for a bare `git
diff` to show modified files before revisions; previously they came at the very
end after all revisions, stashes, local branches, remote branches, and tags.
That seems sensible to me?

As I understand the completions file, it seems to me that the intention was for
`git diff src/` to only show modified files to begin with ­ it
previously/currently shows them all, so we might want to add a `-n 'not ...'`
condition for `git diff` to prevent that.
2024-11-10 12:55:32 -06:00
Peter Ammon
dff454b1c7
Rework git detection for macOS
fish by default shows a git-aware prompt. Recall that on macOS, there are
two hazards we must avoid:

1. The command `/usr/bin/git` is installed by default. This command is not
actually git; instead it's a stub which pops open a dialog proposing to
install Xcode command line tools. Not a good experience.
2. Even after installing these tools, the first run of any `git` or other
command may be quite slow, because it's now a stub which invokes `xcrun`
which needs to populate a cache on a fresh boot. Another bad experience.

We previously attempted to fix this by having `xcrun` print out its cache
path and check if there's a file there. This worked because `xcrun` only
lazily created that file. However, this no longer works: `xcrun` now
eagerly creates the file, and only lazily populates it. Thus we think git
is ready, when it is not.

(This can be reproduced by running `xcrun --kill-cache` and then running
the default fish shell prompt - it will be slow).

Change the fix in the following way: using sh, run `/usr/bin/git --version;
touch /tmp/__fish_git_ready` in the background. Then detect the presence of
/tmp/__fish_git_ready as a mark that git is ready.

Fixes #10535
2024-11-09 12:46:06 -08:00
Johannes Altmanninger
2543b8198d Fix crash when sprintf width argument overflows u64
Given "printf %18446744073709551616s", we parse the number only in
the printf crate, which tells us that we overflowed somwhere (but
not where exactly).
2024-11-09 08:16:08 +01:00
Mahmoud Al-Qudsi
9fddc3e887
Emit only sane pgid value for jobs output (#10833)
We were previously printing the internal `INVALID_PID` value (since removed),
which was a meaningless `-2` constant, when there was no pgid associated with a
job.

This PR changes that to `-` to indicate no pgid available, which I prefer over
something like `0` or `-1`, but will cause problems for code that is hardcoded
to convert this field to an integral value.
2024-11-08 10:33:30 -06:00
David Adam
2279b47178 CHANGELOG: work on 4.0.0
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
Lock threads / lock (push) Has been cancelled
2024-11-07 23:52:29 +08:00
Dezhi Wu
5405833822 feat(completion): Add kops.fish completion
[kOps] is a set of tools for installing, operating, and deleting Kubernetes
clusters.

[kOps]: https://github.com/kubernetes/kops/
2024-11-07 23:13:09 +08:00
Johannes Altmanninger
5e3fdf3320 Fix regression causing crash when we should clamp negative wcwidth
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
Fixes c41dbe455 (Also use control pictures for pager prefix,
2024-10-19).

Fixes #10836
2024-11-07 07:36:36 +01:00
Fabian Boehm
373c5b1e14 fixup! Cursor visible sequence
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
Whoops, picked the wrong part of cnorm
2024-11-06 19:03:50 +01:00
Fabian Boehm
56718c31b1 reader: Comment the OSC 133 marker sequences 2024-11-06 19:01:17 +01:00
Fabian Boehm
c1fbe237c9 Make cursor visible after commands
Just like we already fix terminal modes if a command left them broken,
having an invisible cursor makes the terminal hard to use and so we
fix it.

We can't really use cnorm/cursor_normal because that often includes
other gunk like making the cursor blink, but it turns out every
terminfo entry agrees on the sequence to make the cursor visible, so
we hardcode it.

Fixes #10834
2024-11-06 19:01:17 +01:00
Fabian Boehm
bfc68345c9 Disable CSI u in Jetbrains terminals
Note: This may not be sent in WSL.

Fixes #10829
2024-11-06 19:01:04 +01:00
Fabian Boehm
4b24fe7daf docs/export: Add a bit on PATH=$PATH:... 2024-11-06 18:50:41 +01:00
Fabian Boehm
0979b9a98b help: Print external URL if no browser was found
This is nicer when you use fish over ssh, and that system does not
have a browser. But the system where your terminal is has one, and so
now you can just click the link.
2024-11-06 18:48:57 +01:00
David Adam
018659bf66 CHANGELOG: work on 4.0.0 2024-11-07 01:09:11 +08:00
David Adam
0d9ad0f23b docs: add short documentation for export
Work on #10541.
2024-11-06 23:47:31 +08:00
David Adam
767ae87191 CONTRIBUTING.rst: update for Rust 2024-11-06 23:27:04 +08:00
David Adam
7f29f09d25 README: updates for Rust / 4.0 2024-11-06 23:22:26 +08:00
Johannes Altmanninger
7debdb75af Fix regression causing fish_cursor_external to be ignored
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
Regressed in 0e97b876e (Simplify fish_vi_cursor, 2024-10-25).
2024-11-06 07:24:00 +01:00
Mahmoud Al-Qudsi
24a077f804 Silence GPG warnings about directory permissions
Some checks failed
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
2024-11-04 16:35:24 -06:00
Mahmoud Al-Qudsi
d7f4ad7ab8 Silence gh warnings re unable to read plugins dir
Unlike the errors, these *do* get printed to stderr.
2024-11-04 16:33:30 -06:00
Mahmoud Al-Qudsi
33a170d614 Replace INVALID_PID constant with Option<NonZeroU32>
If we end up using this in more places, we can create a `Pid` newtype.
Note that while the constant is no longer used in code, its previous value of -2
is still printed by `jobs` when no pgid is associated with a job. I will open a
PR to change this to something else, likely either `0` or `-`.
2024-11-04 16:19:22 -06:00
Mahmoud Al-Qudsi
d1a2923d72 Fix doc comments for CancelBehavior 2024-11-04 15:49:33 -06:00
Mahmoud Al-Qudsi
8aed929f5e Fix broken changelog formatting
Some checks failed
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
Lock threads / lock (push) Has been cancelled
2024-11-03 13:53:42 -06:00
David Adam
e5040cbbaf CHANGELOG: work on 4.0.0
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
2024-11-03 22:43:25 +08:00
Peter Ammon
23941ea9ca
Don't try locking the history file if mmap returns ENODEV
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
If we try to memory map the history file, and we get back ENODEV meaning that
the underlying device does not support memory mapping, then treat that as a hint
that the filesystem is remote and disable history locking.
2024-11-02 12:09:51 -07:00
Peter Ammon
344b072e82
Further expand the list of filesystems considered remote
Incorporate additional file systems from
https://github.com/coreutils/gnulib/blob/master/lib/mountlist.c#L237-L253
by hunting down their magic numbers.

In the future we could consider switching to f_fstypename.
2024-11-02 11:59:34 -07:00
Johannes Altmanninger
cfcf415db7 Render overflown commandline in entirety just before executing
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
As of 04c913427 (Limit command line rendering to $LINES lines,
2024-10-25), we only render a part of the command line.  This removes
valuable information from scrollback.
The reasons for the limit were
1. to enable redrawing the commandline (can't do that if part of it
   is off-screen).
2. if the cursor is at the beginning of the command-line, we can't
   really render the off-screen suffix (unless we can tell the terminal
   to scroll back after doing that).

Fortunately these don't matter for the very last rendering of a
command line.  Let's render the entire command just before executing,
fixing the scrollback for executed commands.

In future, we should fix it also for pre-execution renderings. This
needs a terminal command to clear part of the scrollback.  Can't find
anything on https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
There is "Erase Saved Lines" but that deletes the entire scrollback.

See the discussion in #10827
2024-11-02 10:25:58 +01:00
Johannes Altmanninger
04d97e936a Remove redundant cursor position invariant check
Since f89909ae3 (Also handle overflown screens if editing pager search
field, 2024-10-27), cursor_arr is never None after the loop.
Assert that by unwrapping.

qa.sh
2024-11-02 10:16:45 +01:00
Johannes Altmanninger
f42beec42e Fix typo in comment 2024-11-02 10:13:37 +01:00
Johannes Altmanninger
85404bf7a9 edit_command_buffer: speed up setting cursor position by line/column
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
alt-e restores the cursor position received from the editor, moving by
one character at a time.  This can be super slow on large commandlines,
even on release builds.  Let's fix that by setting the coordinates
directly.
2024-11-01 20:09:55 +01:00
Johannes Altmanninger
6525e3d11a edit_command_buffer: silence error when editor reports out-of-bounds line number
This happens when using alt-e to edit the command buffer,
adding some lines, leaving the cursor at the end
and quitting the editor without saving.

Let's avoid the noisy error that has sort of bad rendering (would
need __fish_echo).
2024-11-01 20:09:55 +01:00
Johannes Altmanninger
3710e98d65 Suppress spurious error when config dir creation fails due to TOCTOU
Some checks failed
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Our recursive create_dir() first calls stat() to check if the directory
already exists and then mkdir() trying to create it. If another (fish)
process creates the same directory after our stat() but before our
mkdir(), then our mkdir() fails with EEXIST. This error is spurious
if there is already a directory at this path (and permissions are
correct).

Let's switch to the stdlib version, which promises to solve this issue.
They currently do it by running mkdir() first and ask stat() later.

This implies that they will only return success even if we don't have
any of rwx permissions on the directory, but that was already a problem
before this change. We silently don't write history in that case..

Fixes #10813
2024-10-31 08:01:31 +01:00