Commit graph

19812 commits

Author SHA1 Message Date
Peter Ammon
9785824794
Factor file testing out of highlighting
Syntax highlighting wants to underline arguments that are files, and in other
cases do disk I/O (such as testing if a command is valid). Factor out this I/O
logic to untangle highlighting, and add some tests. No functional change
expected.
2025-01-12 15:10:11 -08:00
Johannes Altmanninger
4f3d6427ce Fix regression causing crash in "commandline -j"
Commit 3fcc6482cb (Fix parse_util_process_extent including too much
on the left, 2024-12-24) changed the process extent based on the
observation that "A\n\n\nB" comprises three tokens with ranges 0..1,
1..2 and 4..5. Prior to that commit, the second process extent was
2..5, which seems a bit weird because it includes newlines.

Weirdness aside, the real reason for changing it was this snippet in
the autosuggestion performer, where we compute the process extent
around cursor, and check if the line at process start matches the
cached search string.

        // Search history for a matching item unless this line is not a continuation line or quoted.
        if range_of_line_at_cursor(
            &command_line,
            parse_util_process_extent(&command_line, cursor_pos, None).start,
        ) == search_string_range

Given "A\n\n\nB" and cursor_pos=1 commit 3fcc6482cb changed the output
from 2..5 to 4..5. This brings problems:
1. leading spaces will not be included (which is probably
   inconsequential but still ugly).
2. the specified cursor position is not included in the given range.

We could paper over 2 by computing min(cursor_pos)
but that would leave 1.

For now let's revert and solve the autosuggestion issue in a less
brittle way.
2025-01-12 19:55:17 +01:00
Fabian Boehm
a1b7c36db5 cmake: Explicitly have tests depend on indent and key_reader 2025-01-12 18:05:50 +01:00
Fabian Boehm
f0eb599ff1 cmake: Remove some more dead gunk
We no longer check for in tree builds anywhere (tests set up their own
tmpdir),
and we no longer support xcode.
2025-01-12 17:52:59 +01:00
Fabian Boehm
7b30745800 cmake: Stop setting up temporary test directory
We already set up a temporary directory for each test in the
test_driver,
so let's stop doing that here.

It took a weirdly long time anyway.
2025-01-12 17:44:31 +01:00
Fabian Boehm
afb1cc21b6 Compile fish_test_helper in CMake again
That means we don't have to recompile it for every test
2025-01-12 17:40:46 +01:00
Fabian Boehm
aa77892be4 fish_indent: Read from stdin, take two
This needs to work both in builtin and command mode.

We should probably clarify how we're passing FDs around, and I suspect
we may close fds in places we don't expect.
2025-01-12 16:17:49 +01:00
David Adam
54fef433e9 Debian packaging: update dependencies
Ubuntu Focal calls the package with col "bsdmainutils", which is a
transitional package on newer version of both Debian and Ubuntu.

Closes #11037.
2025-01-12 21:19:59 +08:00
Fabian Boehm
b2fe405365 Revert "fish_indent: Correctly read from builtin stdin"
Using Arguments here breaks the `command fish_indent` case.

Probably needs to directly use a BufReader.

This reverts commit ab1b6bcea5.
2025-01-12 13:43:51 +01:00
Fabian Boehm
ab1b6bcea5 fish_indent: Correctly read from builtin stdin
This still used read_file, but we don't *really* have an fd if we're
connected to another builtin.
2025-01-12 13:15:39 +01:00
David Adam
1b0c53e30e .gitattributes: fixup e4674cd7
Actually set the attribute on the file 🤦 and also exclude the
directory.
2025-01-12 11:32:34 +08:00
David Adam
44555de69a update .gitattributes
Reflect the current state of the codebase
2025-01-12 10:46:34 +08:00
David Adam
e4674cd7b5 .cargo/config.toml: exclude from tarball
Various commits have added bits to .cargo/config.toml. Unfortunately,
this file needs to be changed by the Linux package builds (debuild, RPM,
OBS etc) with the results of `cargo vendor`, to support building in
isolated environments.

These environments - especially Debian's dpkg-buildpackage/debuild - do
not make it easy to alter a file which already exists in the tarball in
an automatic way. dpkg-buildpackage in particular requires all changes
to be made in the form of patches.

Just exclude .cargo/config.toml from the tarballs for now. This means
that the stanzas it includes _will not apply_ to builds made from
tarballs, which includes releases and development builds made using the
OBS/Launchpad PPAs.
2025-01-12 10:34:16 +08:00
Fabian Boehm
a2c48539cd cmake: Remove cachedir for test_driver
This can race when compiling fish_test_helper (one process compiles,
the other checks, ...)

Part of #11036
2025-01-11 22:08:18 +01:00
Fabian Boehm
d9f3cf332c deny.toml: Add Unicode license 2025-01-11 21:14:01 +01:00
Fabian Boehm
b43b0e0195
Rewrite test driver in python (#11028)
This replaces the test_driver.sh/test.fish/interactive.fish system with a test driver written in python that calls into littlecheck directly and runs pexpect in a subprocess.

This means we reduce the reliance on the fish that we're testing, and we remove a posix sh script that is a weird stumbling block (see my recent quest to make it work on directories with spaces).

To run specific tests, e.g. all the tmux tests and bind.py:

tests/test_driver.py target/release/ tests/checks/tmux*.fish tests/pexpects/bind.py
2025-01-11 21:13:19 +01:00
Johannes Altmanninger
51adba6ee0 Restore autosuggestion after corrected typo
Backspace signals that the user is not happy with the commandline,
and by extension the autosuggestion.

For this reason, backspace suppresses autosuggestions until the next
text insertion.

However if I
1. type something that has an autosuggestion
2. type *one* wrong letter (removing the autosuggestion)
3. type backspace

backspace does not visibly suppress any autosuggestion but rhater
signal that the user wants to go back to the previous state of the
commandline, which does have an autosuggestion.

Enable this scenario by caching the autosuggestion when it's
invalidated. On certain edits that make the cached autosuggestion
valid again, restore it from the cache.  Currently, only do this up
to a single backspace.  Could extend that in future.

This implementation is really bad.. but it's a start.
Weirdly, it does not restore the cache on undo; but that's
inconsequential because undo doesn't suppress autosuggestion as
of today.

Closes #3549
2025-01-11 18:58:49 +01:00
kerty
d06ee1ee9c Fix .cpp to .rs and redundant closure 2025-01-11 18:58:49 +01:00
Johannes Altmanninger
7c539b9539 Rename the readline function for deleting active history item
history-pager-delete now also works for regular history search,
so rename it.
2025-01-11 18:58:49 +01:00
Mahmoud Al-Qudsi
f8b245eb31 completions/zfs: Add encryption-related completions 2025-01-11 10:44:40 -06:00
Johannes Altmanninger
4a6d8d0b3a Allow alt-enter and friends to insert into search field
Since this is user-visible, copy the logic rather than extracting
a function.
2025-01-11 13:50:08 +01:00
Johannes Altmanninger
0f1408e0ea Also autosuggest lines from multi-line command lines in history
My history often has erroneous single-line commands followed by
corrected versions. Sometimes the corrected versions only exist within
a multi-line commandline.  This means that autosuggestion skips over
the corrected versions and return a false positive.

Fix that by splitting the commandline into lines and suggesting those,
in reverse chronological order.

One other wart: shift-delete won't delete such autosuggestions from
history; instead it will flash the screen.

Line boundaries are not the best heuristic but they are an
improvement for the most part and fits with the current approach
where autosuggestion always operates on the entire line.

In future we should operate on processes and jobs.  But it may be
tricky - a backgrounding `&` should probably be included (in both?)
but `&&` or `;` probably not.

See also the discussion in
1c4e5cadf2 (diff-267c9f4da66412a9f439ac08d224356fe24265b5e1cebb6c44c2d55b96414513R59)
2025-01-11 13:50:08 +01:00
Johannes Altmanninger
411745ebce shift-delete to only delete from history if cursor at autosuggestion
If there is no history search or autosuggestion, shift-delete acts
as backspace, matching native macOS behavior.

I'm not sure if we want to keep that amount of overloaded behavior,
but let's assume so for now.

If that assumption holds, it may be confusing that shift-delete
deletes the autosuggestion if the cursor is here

	echo some command with autosuggstion
		^

So let's only do that if the cursor is actually at the autosuggestion,
I guess.
2025-01-11 13:50:08 +01:00
Johannes Altmanninger
f448ddd579 shift-delete to stop trying to delete completion-based autosuggestions from history
shift-delete attempts to delete the autosuggestion from history even
if the autosuggestion is not from history.

This is weird. We probably shouldn't do this. Let's flash the
commandline instead to try to reduce confusion.
2025-01-11 13:50:08 +01:00
Daniel Fleischer
29c45100fa
Add lazygit completions (#11019) 2025-01-10 21:21:54 -06:00
Mahmoud Al-Qudsi
a4f91a8543 Don't override CTEST_PARALLEL_LEVEL env variable
I think the dynamic detection patch ends up overriding the environment variable
set by CI (if present), because `if(NOT CTEST_PARALLEL_LEVEL)` would define to
false even if an environment variable of that name existed then we end up
explicitly assigning the environment variable by that name upon invocation with
`env`.
2025-01-10 19:21:28 -06:00
Fabian Boehm
1f45ab63d1 staticbuilds: Build pcre2 statically for macos 2025-01-10 14:44:31 +01:00
Fabian Boehm
0f6e85466a CHANGELOG key_reader/indent as builtins 2025-01-10 14:16:01 +01:00
Mahmoud Al-Qudsi
417b2eb8c6 Re-add dynamic CTEST_PARALLEL_LEVEL detection
When it is not hard-coded in the environment variable of the same name.
2025-01-10 14:12:46 +01:00
Mahmoud Al-Qudsi
3bbfaf532e Bump CTEST_PARALLEL_LEVEL to match CTEST_BUILD_PARALLEL_LEVEL
This is an experiment to see if it causes any of the tests to flake and/or if it
even appreciably speeds up CI to begin with.

I note that there are tests added in 8bf8b10 that mutate global terminal state
but also note that local tests without CTEST_PARALLEL_LEVEL set at all have been
running to completion just fine without any observed flakiness *and* that our
Cirrus CI tests have this hard-coded to 6.
2025-01-10 14:12:46 +01:00
Fabian Boehm
c7358d14c8 Make fish_indent available as a builtin 2025-01-10 14:12:19 +01:00
Fabian Boehm
67eb0e8317 Make fish_key_reader available as a builtin
This brings us closer to making fish available as a single file.
2025-01-10 14:12:19 +01:00
Benjamin Weis
83586aebcc Update German translation 2025-01-10 14:10:36 +01:00
Mahmoud Al-Qudsi
c1a43b896c Skip select ebadf test under WSLv1 due to a WSL bug
WSLv1 won't return EBADF (or any error) if the fd was closed mid-select.
2025-01-09 17:30:08 -06:00
Mahmoud Al-Qudsi
0fcb2f7590 completions/cargo: Add --ignore-rust-version
New to 1.85; bypasses MSRV checks specified by `resolver = 3` or in
.cargo/config.toml
2025-01-09 17:06:31 -06:00
Mahmoud Al-Qudsi
e3868effe1 Update cargo dependencies 2025-01-09 17:00:30 -06:00
Mahmoud Al-Qudsi
b9c6806e45 Configure cargo to respect MSRV
The new 1.84 release has a new feature that makes `cargo update` MSRV-aware.

This is what it looks like in practice:

    Updating crates.io index
    Updating git repository `https://github.com/fish-shell/rust-pcre2`
From https://github.com/fish-shell/rust-pcre2
 * [new tag]         0.2.9-utf32 -> origin/tags/0.2.9-utf32
     Locking 7 packages to latest Rust 1.70 compatible versions
    Updating cc v1.2.6 -> v1.2.7
    Updating phf v0.11.2 -> v0.11.3
    Updating phf_codegen v0.11.2 -> v0.11.3
    Updating phf_generator v0.11.2 -> v0.11.3
    Updating phf_shared v0.11.2 -> v0.11.3
    Updating siphasher v0.3.11 -> v1.0.1
    Updating syn v2.0.94 -> v2.0.95
2025-01-09 16:50:13 -06:00
Fabian Boehm
b8208d72f7 Remove test for broken tmux output
Quite flaky on CI.

See #11036
2025-01-09 21:06:15 +01:00
Fabian Boehm
52cb42ba3d Remove unused fish_iswgraph 2025-01-09 20:20:28 +01:00
Klaus Hipp
5c25d3c3b1 Fix completion typos 2025-01-09 16:51:39 +01:00
phanium
ef7aa793c6 Fix missing of builtin token description 2025-01-09 16:49:41 +01:00
Fabian Boehm
fac29e775a type: Do not translate the type "builtin"
This is a functional string, it should not be translated.

And we do not translate the others.
2025-01-09 16:42:28 +01:00
César Sagaert
00c7baf68c
DNF5 completion support (#11035)
* dnf5 completions

* address comments
2025-01-09 16:35:46 +01:00
Johannes Altmanninger
0e512f8033 Fix spurious blank lines when executing scrolled commandline
The result of

	commandline -i ": '$(seq $LINES)"\n"first scrolled line'"

is a commandline that is scrolled by one line.

Before executing that commandline, we move the cursor down by one
too many line. This is a regression from 610338cc70 (On undo after
execute, restore the cursor position, 2024-12-21). Fix that.

The test also demonstrates an unrelated problem, probably specific
to tmux.
2025-01-09 14:43:21 +01:00
Fabian Boehm
8304fd0fd0 tmux-job: Add more sleeps 2025-01-08 19:10:38 +01:00
Fabian Boehm
f4f786633d pexpects/bind: Add missing expect_prompt 2025-01-08 19:10:38 +01:00
Fabian Boehm
ec3b3fe321 pexpects/signals: Decrease a timeout that should be reached
Saves ~10% of the *total* testing time (except for `cargo test`)
2025-01-08 19:10:38 +01:00
Fabian Boehm
d3762f11b5 tmux-commandline: Print $LINES
Maybe this'll show us what the issue on NetBSD is
2025-01-08 19:10:38 +01:00
Fabian Boehm
6db0f39676 exit_nohang: Harden a bit 2025-01-08 19:10:38 +01:00
Branch Vincent
7970ca55af
completions: add fish-lsp (#11017) 2025-01-08 11:25:36 -06:00