Commit graph

19568 commits

Author SHA1 Message Date
Fabian Boehm
0e62178320 Only apply kitty protocol MC hack in MC
This deactivated it everywhere
2024-10-26 22:24:22 +02:00
Johannes Altmanninger
bd9fee417b Use kitty keyboard protocol again for recent Midnight Commander
See https://midnight-commander.org/ticket/4597
2024-10-26 19:55:48 +02:00
Johannes Altmanninger
9ef76860e6 Default Vi cursor shapes for insert/replace mode
Let's provide a sensible default here. Use a line for "insert" and an
underline for "replace_one" mode.  Neovim does the same, it feels pretty
slick.

As mentioned in #10806
2024-10-26 08:25:12 +02:00
Johannes Altmanninger
5760a1afcf Don't reset the fish_cursor_selection_mode in fish_default_key_bindings
As of the parent commit, __fish_vi_key_bindings_remove_handlers
should be working properly now, so this is no longer necessary That
function also cleans up other stuff like fish_cursor_end_mode, that
fish_default_key_bindings doesn't know anything about.

Also this fixes a spurious exit status of 4 in some scenarios.
2024-10-26 08:25:12 +02:00
Johannes Altmanninger
b05e071238 Properly remove Vi mode when switching to different bindings
fish_key_bindings may be set directly
or via fish_{default,vi}_key_bindings.

The latter use "set --no-event" to simplify their control
flow.  This (24836f965 (Use set --no-event in the key binding
functions, 2023-01-10)) broke Vi mode cleanup, since Vi mode
uses a variable hook.  Let's update this variable also when using
fish_{default,vi}_key_bindings.  Another reason to keep this variable
in sync is to make the fish_key_bindings handlers working as expected.
2024-10-26 08:22:19 +02:00
Johannes Altmanninger
8eaa16542a Extract function for changing key bindings 2024-10-26 08:21:12 +02:00
Johannes Altmanninger
832cda26f6 Fix external cursor not being restored on exiting Vi mode 2024-10-26 08:21:12 +02:00
Johannes Altmanninger
0e97b876ea Simplify fish_vi_cursor
This command has redundant source statements which need a lot
of escaping. Also, let's extract a function, to be modified in a
following commit.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
aca8058717 Remove obsolete optimization in default binding initialization
This special case was added in fb2ed355e (Improve fork reporting Save a
couple of forks during init, 2012-04-24) but the reason for it is gone.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
dea7841611 Fix Vi replace mode regression not being able to append to command line
Regressed in d51f66964 (Vi mode: avoid placing cursor beyond last
character, 2024-02-14).
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
c2cde317f2 Remove stale FISH_UNIT_TESTS_RUNNING workaround
This exists to make sure our assertions pass independent of the
terminal but now we unconditionally print __fish_cursor_xterm.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
04c9134275 Limit command line rendering to $LINES lines
Render the command line buffer only until the last line we can fit
on the screen.

If the cursor pushes the viewport such that neither the prompt nor
the first line of the command line buffer are visible, then we are
"scrolled". In this case we need to make sure to erase any leftover
prompt, so add a hack to disable the "shared_prefix" optimization
that tries to minimize redraws.

Down-arrow scrolls down only when on the last line, and up-arrow always
scrolls up as much as possible.  This is somewhat unconventional;
probably we should change the up-arrow behavior but I guess it's a
good idea to show the prompt whenever possible.  In future we could
solve that in a different way: we could keep the prompt visible even
if we're scrolled. This would work well because at least the left
prompt lives in a different column from the command line buffer.
However this assumption breaks when the first line in the command
line buffer is soft-wrapped, so keep this approach for now.

Note that we're still broken when complete-and-search or history-pager
try to draw a pager on top of an overfull screen.  Will try to fix
this later.

Closes #7296
2024-10-25 17:35:42 +02:00
Johannes Altmanninger
50333d8d00 Fix code duplication in commandline rendering
Will use this in the next commit.
2024-10-25 17:11:54 +02:00
Peter Ammon
0d5e6f356e
Correct spelling of "courtesy" 2024-10-24 20:25:22 -07:00
Mahmoud Al-Qudsi
9c960d6af8 Fix number of characters consumed for VT200 mouse tracking
It's a 9-char CSI and we've read 3 (`<ESC>[T`), so we need to read six more.
Verified against the previous C++ codebase and couldn't find a reason for the
change to consuming 10 chars in a `git blame` run.
2024-10-24 11:22:52 -05:00
Mahmoud Al-Qudsi
daa2f2d023 Document max CSI parameter count 2024-10-24 10:36:00 -05:00
Mahmoud Al-Qudsi
21860cbd39 Fix panic parsing CSIs
The array lengths were transposed, so attempting to parse a CSI with more than 4
parameters would go out of bounds and panic.
2024-10-24 10:28:04 -05:00
Johannes Altmanninger
1b644226ec CHANGELOG: minor update 2024-10-22 08:55:08 +02:00
Johannes Altmanninger
d9633f2b38 Remove stale docs about fish_vi_force_cursor
Remove in 983746a69 (fish_vi_cursor: Remove terminal checks, 2024-08-30).
2024-10-21 21:53:32 +02:00
Johannes Altmanninger
5b249dbb41 test_env: remove stale env sanitization
These are unused since 983746a69 (fish_vi_cursor: Remove terminal checks,
2024-08-30).
2024-10-21 12:56:55 +02:00
Ilya Grigoriev
9c96ae0d40 ISSUE_TEMPLATE.md: Reset XDG_DATA_DIRS in suggested commands
This turned out to be relevant in https://github.com/fish-shell/fish-shell/issues/10800#issuecomment-2425170531 .
2024-10-21 12:54:43 +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
30cba03bf9 Make SIGTERM handler async-signal-safe again 2024-10-21 09:30:47 +02:00
Johannes Altmanninger
ae7b401029 completions/set: show innermost scope in variable description
A side effect of cd9e50c2c (completions/set: Complete variables of all scopes
when setting, 2024-10-03) is that

    HOME=$(mktemp -d) fish
    fish_config choose ayu\ Light
    set -S fish_color_

gives only completions that have the "Universal variable" description even
though most colors are also defined in the global scope which usually takes
precedence.

Fix this by reordering the completions. (The last-added completion is shown
first which is very surprising, we should change that).

This is not perfect; if the user has already specified `-U`, then we should
probably not show description of the global version.  But that's still
worth the trade that this commit makes.  Finally, the description could show
something like "Defined in universal and global scope" etc.
2024-10-20 07:55:04 +02:00
Johannes Altmanninger
2e4f98b51c Do not add a space after completing inside brace expansion
Another everyday annoyance, has been for many years.
2024-10-19 22:06:05 +02:00
Johannes Altmanninger
c41dbe4551 Also use control pictures for pager prefix
The test case shows that the pager rendering is not quite right.  It renders
'{\', leaving out the newline.  This rendering is ambiguous.

Let's fix it by rendering \n as control picture, like we do for other control
characters in the pager.
2024-10-19 22:05:49 +02:00
Johannes Altmanninger
f5c6829670 Fix pager being blank when token prefix contains newline
Given

    $ echo {\
    C

where C is the cursor.
Completions have prefix "{\\\n".
Since \n has a wcwidth of -1, this line always fails

    let prefix_len = usize::try_from(fish_wcswidth(&self.prefix));

This triggers uncovers a regression in 43e2d7b48 (Port pager.cpp, 2023-12-02),
where we end up computing comp_width=0 for all completions.

Fix this. Test in the next commit.

The C++ version added the prefix width only if the completion had a valid
width. That seems wrong, let's do it always (if the prefix width is valid).
2024-10-19 22:05:49 +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
f4ff312265 Fix typo in docs 2024-10-19 22:04:54 +02:00
Johannes Altmanninger
3d5ef2bcf5 Fix inverted condition in panic handler
Fixes 139d204c (Restore terminal state again in panic handler, 2024-10-12).
2024-10-19 22:04:54 +02:00
Rikuki IX
85801b443a
feat(completion): add lsb_release completion (#10795) 2024-10-19 13:06:06 -05:00
Jason Nader
6082c3f77a
completions/diff: allow file completion for --unified (#10796)
* completions/diff: allow file completion for --unified

* Update diff.fish

* Update diff.fish
2024-10-19 16:58:29 +02:00
Johannes Altmanninger
b625c566b1 Remove workaround for WezTerm configured with enable_kitty_keyboard=true
On a German keyboard, with a German keymap, and this ~/.wezterm.lua

    local wezterm = require 'wezterm'
    local config = wezterm.config_builder()
    config.enable_kitty_keyboard = true
    return config

when I press shift+# (which is single quote)
WezTerm sends the CSI u encoding shift-'.

Because of this, we completely disable kitty progressive enhancements and
modifyOtherKeys on WezTerm.

It makes no sense for every single app to work around WezTerm violating the
protocol. All these workarounds just create unnecessary version dependencies.
Also our workaround is brittle; it breaks as soon as you're inside something
like SSH.
Least importantly, the workarond prevents users of English keyboard layouts
to easily use the new features.

Since it seems so easy to work around by settting "enable_kitty_keyboard = false",
and most importantly, since that's the default, it seems better to remove
the workaround to simplify the world.

See #10663
2024-10-17 11:30:30 +02:00
Johannes Altmanninger
3869b59000 Add some context to changelog on new alt arrow bindings 2024-10-17 11:30:30 +02:00
Fabian Boehm
a1e74007d2 CHANGELOG colorscheme 2024-10-17 11:14:01 +02:00
Fabian Boehm
81ff6db62d default color scheme: Make commands "normal" color
This makes the default colorscheme less colorful for two reasons:

1. It makes it a little less "angry fruit salad"
2. Some terminals (like Microsoft's Windows Terminal) have a terrible
blue default that contrasts badly against a black background

The alternative is to make *parameters* "normal" and give commands the
current parameter color (cyan). But I've seen cyan be quite blue and
quite green depending on the terminal, so I don't want to rely on it.
2024-10-15 21:21:30 +02:00
Fabian Boehm
0dfc490721 build.rs: Use Cargo_PKG_VERSION if no version could be found
`cargo build --git` clones a git repo without any tags, so you get a
version like

```
fish, version f3fc743fc
```

which is *just* the commit hash and missing the "3.7.1-NUM-g" part.

So, if we hit that case (detected because it has no ".", under the
assumption that we'll never make a version that's just "4" instead of
"4.0"), we prepend the version from Cargo.toml.
2024-10-15 13:10:07 +02:00
Fabian Boehm
de13e6f9af complete: Only describe commands if the function exists
This shells out to __fish_describe_command, but if the install is
incomplete that will trigger the command-not-found handler.
2024-10-15 13:09:02 +02:00
Fabian Boehm
ebf19c22fd fish_config: Find fish via fish-path 2024-10-15 13:09:02 +02:00
Mahmoud Al-Qudsi
8447c32d65 __fish_indent: Cache fish_indent location 2024-10-14 19:01:41 -05:00
exploide
7bb6ce5156 completions: added arping 2024-10-14 15:34:11 -07:00
EmilyGraceSeville7cf
1148b790bb
feat(completion): support winetricks command 2024-10-14 15:11:45 -07:00
exploide
2f2b4c8e99 completions: updated hashcat completions 2024-10-14 12:12:07 -07:00
Fabian Boehm
9f92d1f204 CI: Remove test deps from the clippy check 2024-10-14 21:02:26 +02:00
Johannes Altmanninger
b4f86bf0f5 Fix installation of pexpect on latest GitHub Actions images
We already use --break-system-packages for macOS but it's not necessary here.
2024-10-14 11:26:08 +02:00
Johannes Altmanninger
a2dc0ef377 Revert "Lock history file before reading it"
Commit 5db0bd5 (Lock history file before reading it, 2024-10-09)
rewrites the history file in place instead of using rename().
By writing to the same file (with the same inode), it corrupts
our memory-mapped snapshot; mmap(3) says:

> It is unspecified whether modifications to the underlying object done
> after the MAP_PRIVATE mapping is established are visible through the
> MAP_PRIVATE mapping.

Revert it (it was misguided anyway).

Closes #10777
Closes #10782
2024-10-14 11:13:46 +02:00
Peter Ammon
fbf0ad98af
Build macOS x86-64 with Rust 1.73.0 in make_pkg.sh
This retains compatibility with macOS 10.9.
Note that Apple Silicon Macs shipped with 10.15, so compatibility for Apple
Silicon is not a concern.
2024-10-13 14:36:02 -07:00
Peter Ammon
9337c20c2e
Stop using the getrandom feature of the rand crate
This feature uses the "getentropy" function which is not supported on
macOS < 10.12.
2024-10-13 12:39:54 -07:00
Johannes Altmanninger
6af96a81a8 Default bindings for token movement commands
There is no natural default binding for token movements. Add the
alt-{left,right,backspace,delete}, breaking some existing behavior.

For example, backward-delete-word is no longer bound to alt-backspace but
only to ctrl-backspace.  Unfortunately some terminals (particularly tmux)
don't support distinguishing ctrl-backspace from ctrl-h yet, so the loss
of alt-backspace may be tragic.

---

I guess we could also add:

    bind alt-B backward-token
    bind alt-F forward-token
    bind ctrl-W backward-kill-token
    bind alt-D kill-token

Those might be intercepted by the terminal on Linux, but I don't know where
that happens.

Tested on foot, kitty, alacritty, xterm, tmux, konsole and gnome-terminal.

Closes #10766
2024-10-13 14:53:45 +02:00
Johannes Altmanninger
2dafe81f97 Builtin source to print error if missing both file argument and piped stdin
Closes #10774
2024-10-13 10:44:38 +02:00