Commit Graph

18427 Commits

Author SHA1 Message Date
Johannes Altmanninger
b77d1d0e2b Stop crashing on invalid Unicode input
Unlike C++, Rust requires "char" to be a valid Unicode code point.  As a
workaround, we take the raw (probably UTF-8-encoded) input and convert each
input byte to a char representation from the private use area (see commit
3b15e995e (str2wcs: encode invalid Unicode characters in the private use
area, 2023-04-01)).  We convert back whenever we output the string, which
is correct as long as the encoding didn't change since the data was input.

We also need to convert keyboard input; do that.

Quick testing shows that our reader drops PUA characters.  Since this patch
converts both invalid Unicode input as well as PUA input into a safe PUA
representation, there's no longer a reason to not add PUA characters to
the commandline, so let's do that to restore traditional behavior.

Render them as � (REPLACEMENT CHARACTER); unfortunately we show one per
input byte instead of one per code point. To fix this we probably need our
own char type.

While at it, remove some special cases that try to prevent insertion of
control characters. I don't think they are necessary. Could be wrong..
2024-02-27 22:59:49 +01:00
Fabian Boehm
f60b6e6cd4 CHANGELOG 2024-02-27 16:28:20 +01:00
Fabian Boehm
78c9482822 Reformat share/**.fish with newlines collapsed 2024-02-27 16:25:01 +01:00
Fabian Boehm
f93a3e9e9b fish_indent: Collapse successive newlines
This makes it so code like

```fish
echo foo

echo bar
```

is collapsed into

```fish
echo foo

echo bar
```

One empty line is allowed, more is overkill.

We could also allow more than one for e.g. function endings.
2024-02-27 16:25:01 +01:00
Mathis Chenuet
73d760560b
Add completion for pstree (#10317)
* Add completion for pstree.fish

* use fish functions, much better
2024-02-26 17:39:11 +01:00
Fabian Boehm
f87c892ed8 Update cc dependency
Removes annoying "running cc --version" and such debug messages.
2024-02-26 16:17:47 +01:00
Fabian Boehm
d0cf07c4b3 Format __fish_cache_sourced_completions 2024-02-26 16:17:47 +01:00
may
66aab66670
add recent commits to completion for git diff (#10321) 2024-02-25 14:36:05 -06:00
Fabian Boehm
46b7e91c91 Update deps
Notably this removes the jobserver dependency
2024-02-24 10:07:47 +01:00
Fabian Boehm
f62f1aaf99 Remove remaining mentions of curses 2024-02-23 16:36:10 +01:00
Fabian Boehm
8712bd5a4b CHANGELOG terminfo 2024-02-22 20:15:24 +01:00
Fabian Boehm
c408342d65 CI: Install terminfo-db on FreeBSD 2024-02-22 20:10:16 +01:00
Fabian Boehm
da6a9bad5f Add additional paths for NetBSD and Nix
These seems weird to add upstream, and we might want to read
more here.
2024-02-22 20:10:16 +01:00
Fabian Boehm
785d784482 Make term warning less shouty
We don't need to know that it tried these five before finally getting
one, the list is *right there*.

It is also very unlikely that someone has "xterm" or "ansi" but not "xterm-256color"

For xterm-256color, we don't warn *at all* because we have that one hardcoded.
2024-02-22 20:10:16 +01:00
Fabian Boehm
75f7cda6ab Add xterm-256color fallback
And use it if $TERM is xterm-256color and could not be found, *without* warning.

These barely change, especially in the parts we use.
2024-02-22 20:10:16 +01:00
Fabian Boehm
8c86336109 Remove useless use of cstring 2024-02-22 20:10:16 +01:00
Fabian Boehm
57317fdaf2 Remove now unused assert helpers 2024-02-22 20:10:16 +01:00
Fabian Boehm
fc794bab4c Switch to the terminfo crate
This allows us to get the terminfo information without linking against curses.

That means we can get by without a bunch of awkward C-API trickery.

There is no global "cur_term" kept by a library for us that we need to invalidate.

Note that it still requires a "unhashed terminfo database", and I don't know how well it handles termcap.

I am not actually sure if there are systems that *can't* have terminfo, everything I looked at
has the ncurses terminfo available to install at least.
2024-02-22 20:10:16 +01:00
Mahmoud Al-Qudsi
2c2ab0c1fa
Always source file after funced (#10318)
... even if the file hasn't changed. This addresses an oddity in the following
case:

* Shell is started,
* function `foo` is sourced from foo.fish
* foo.fish is *externally* edited and saved
* <Loaded definition of `foo` is now stale, but fish is unaware>
* `funced foo` loads `type -p foo` showing changed definition, user exits
  $EDITOR saving no changes (or with $status 0, more generally).
* Stale definition of `foo` remains
2024-02-22 12:45:20 -06:00
Jadi
e207f8464e Make descriptions shorter: iex, jhipster, lpadmin, mocp, rmmod 2024-02-22 18:59:08 +01:00
Jason Nader
fc58b9c68f completions: add ssh -D option 2024-02-22 18:58:04 +01:00
Paul Gier
6c9c033126 functions: handle hostname starting with dash
If a hostname starts with a dash `-` character, the prompt_hostname function
fails because the `string` function interprets it as an option instead
of an argument.
2024-02-22 21:21:31 +08:00
Jason Nader
2f332f0019 completions: update 'echo' 2024-02-20 17:40:35 +01:00
Fabian Boehm
b7cc7db93c fish_key_reader: Remove unnecessary parser
I have no idea what this would be used for, it's instantiated, we set
is_interactive, and then we never use it.
2024-02-20 16:55:32 +01:00
Fabian Boehm
9a2729d298 Fix builtin read crash with negative nchars
Also make it simpler by just passing it along as a usize
2024-02-19 18:48:21 +01:00
Fabian Boehm
8667ed5c17 fish_git_prompt: Count type changes as dirty too
Fixes #10305
2024-02-17 08:37:22 +01:00
Johannes Altmanninger
b687ef036b Fix regression of C-e always accepting autosuggestion 2024-02-17 01:34:32 +01:00
Johannes Altmanninger
8c91d1421a Add some sleeps to fix the tmux-history-search test 2024-02-17 01:33:29 +01:00
Fabian Boehm
0d9c737a47 builtins/history: Remove unnecessary unwrap 2024-02-16 19:40:42 +01:00
Fabian Boehm
46afbea72b exec: Pass some cstrs as cstr instead of converting to ptr and back 2024-02-16 19:40:41 +01:00
Fabian Boehm
7e8a4dbe5c highlight: Stop copying pending variables 2024-02-16 19:40:41 +01:00
Fabian Boehm
1160bf84ed input: Resolve a TODO 2024-02-16 19:40:39 +01:00
Fabian Boehm
035948eb2f Correct and shorten a comment
There is no more "input.cpp"
2024-02-16 19:11:45 +01:00
Fabian Boehm
983af732dd Add test for history pager crash 2024-02-16 18:43:16 +01:00
Fabian Boehm
9ff02d6a7f Fix crash in the history pager
Delete the last shown entry and it'll subtract with overflow
2024-02-16 18:22:37 +01:00
Johannes Altmanninger
26ea024e74 completions/xdg-mime: fix off-by-one error and allow multiple filetypes 2024-02-16 07:45:22 +01:00
Johannes Altmanninger
2915c525fa Revert "history: Skip lines with tabs when importing from bash"
We still don't support tabs but as of the parent commit, there are no more
weird glitches, so it should be fine to recall those lines?

This reverts commit cc0e366037.
2024-02-15 01:39:45 +01:00
Johannes Altmanninger
0627c9d9af Render control characters as Unicode Control Pictures
Inserting Tab or Backspace characters causes weird glitches. Sometimes it's
useful to paste tabs as part of a code block.

Render tabs as "␉" and so on for other ASCII control characters, see
https://unicode-table.com/en/blocks/control-pictures/. This fixes the
width-related glitches.

You can see it in action by inserting some control characters into the
command line:

	set chars
	for x in (seq 1 0x1F)
		set -a chars (printf "%02x\\\\x%02x" $x $x)
	end
	eval set chars $chars
	commandline -i "echo '" $chars

Fixes #6923
Fixes #5274
Closes #7295

We could extend this approach to display a fallback symbol for every unknown
nonprintable character, not just ASCII control characters.

In future we might want to support tab properly.
2024-02-15 01:39:45 +01:00
Johannes Altmanninger
d3b700f98c Promote debug-only assertion 2024-02-15 01:27:23 +01:00
Johannes Altmanninger
a1ed63fd83 Make wcwidth an isize
Seems more consistent with the rest of our code.
2024-02-15 01:27:23 +01:00
Johannes Altmanninger
8545b5debe Remove obsolete no_mangle directives 2024-02-15 01:22:37 +01:00
Johannes Altmanninger
4cb766324b Fix regression in forward-single-char
This crashes if the autosuggesion is exhausted.  C++ used

    autosuggestion.text.substr(pos, 1)

which throws if pos is OOB but not if pos + 1 is.
2024-02-14 10:52:38 +01:00
Johannes Altmanninger
2137467f0b Trigger rebuild if builtin source changes 2024-02-12 22:28:29 +01:00
ridiculousfish
e1d539c7b6 Stop using errno for input_terminfo_get_sequence errors
Use a real error type. Fixes a TODO and cleans up the code.
2024-02-11 15:03:27 -08:00
ridiculousfish
5021639db1 Correct some comments and duplicative error messages
If we fail to create a pipe, we will report that fact in multiple places; remove
some redundant error reporting.
2024-02-11 12:16:58 -08:00
PolyMeilex
b9ba9e57e8 Use nix & Results 2024-02-11 11:40:27 -08:00
PolyMeilex
971d774e67 Use OwnedFd in AutoClosePipes 2024-02-11 11:40:27 -08:00
David Adam
59fe52851e CMake: add entry point to binary dependency 2024-02-11 21:07:43 +08:00
David Adam
7dfe6f2c07 common.rs: drop unused PACKAGE_BUGREPORT constant 2024-02-11 21:06:37 +08:00
Henrik Hørlück Berg
59fa7479ee
Add documentation and release notes for #10282 2024-02-11 12:43:13 +01:00