__fish_cursor_xterm: Ignore unknown cursor settings

This prevents leaking the escape sequence by printing nonsense, and it
also allows disabling cursor setting by just setting the variable to
e.g. empty.

And if we ever added any shapes, it would allow them to be used on new
fish and ignored on old

Fixes #9698
This commit is contained in:
Fabian Boehm 2023-03-31 20:03:24 +02:00
parent e78560d927
commit e45bddcbb1
2 changed files with 5 additions and 0 deletions

View file

@ -429,6 +429,8 @@ The ``fish_vi_cursor`` function will be used to change the cursor's shape depend
Additionally, ``blink`` can be added after each of the cursor shape parameters to set a blinking cursor in the specified shape.
Fish knows the shapes "block", "line" and "underscore", other values will be ignored.
If the cursor shape does not appear to be changing after setting the above variables, it's likely your terminal emulator does not support the capabilities necessary to do this. It may also be the case, however, that ``fish_vi_cursor`` has not detected your terminal's features correctly (for example, if you are using ``tmux``). If this is the case, you can force ``fish_vi_cursor`` to set the cursor shape by setting ``$fish_vi_force_cursor`` in ``config.fish``. You'll have to restart fish for any changes to take effect. If cursor shape setting remains broken after this, it's almost certainly an issue with your terminal emulator, and not fish.
.. _vi-mode-command:

View file

@ -8,6 +8,9 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)'
set shape 4
case line
set shape 6
case '*'
# Unknown shape
return
end
if contains blink $argv
set shape (math $shape - 1)