Commit graph

13042 commits

Author SHA1 Message Date
ridiculousfish
6e11750479 Make the global feature set an instance variable
Allow it to be inlined.
2020-09-12 17:35:21 -07:00
Fabian Homborg
1c43030d79 cd: Remove unneeded code
This now works in cd proper, so it's unneeded in the function.
2020-09-12 20:17:30 +02:00
Fabian Homborg
5fd3ad624f screen: Show suggestion if the commandline was pushed to a new line
Pretty sure this was just overlooked, the comment mentions that it
should happen and it seems to work.

Fixes #7213.
2020-09-12 20:09:26 +02:00
Fabian Homborg
0072367512 fish_add_path: Don't resolve symlinks
The case for symlinked directories being duplicated a lot isn't there,
but there *is* a usecase for adding the symlink rather than the
target, and that's homebrew.

E.g. homebrew installs ruby into /usr/local/Cellar/ruby/2.7.1_2/bin,
and links to it from /usr/local/opt/ruby/bin. If we add the target, we
would miss updates.

Having path entries that point to the same location isn't a big
problem - it's a path lookup, so it takes a teensy bit longer. The
canonicalization is mainly so paths don't end up duplicated via weird
spelling and so relative paths can be used.
2020-09-12 19:28:01 +02:00
Fabian Homborg
568f9031aa builtin realpath: Add --no-symlinks option
Taken from GNU realpath, this one makes realpath not resolve symlinks.

It still makes paths absolute and handles duplicate and trailing
slashes.

(useful in fish_add_path)
2020-09-12 19:26:04 +02:00
Fabian Homborg
8cf389baf2 tokenizer: Switch to !iswblank instead of iswgraph
Fixes #7328
2020-09-11 23:53:26 +02:00
Fabian Homborg
68ab016267 CHANGELOG/README python 3-ification
Fixes #6537.

[ci skip]
2020-09-11 21:21:04 +02:00
Fabian Homborg
691deac1e4 Print default error in the pacman cnf-handler
Pacman *only* prints the package if it exists, no error or anything.

Fixes #7327.
2020-09-11 20:58:02 +02:00
Fabian Homborg
0e9b496bba Fix bigword bindings with single-character words
With a commandline like

```
a b c d
```

and the cursor at the beginning, this would eat "a b", which isn't a
sensible bigword.

Bigword should be "a word, with optional leading whitespace".

This was caused by an overly zealous state-machine that always ate one
char and only *then* started eating leading whitespace.

Instead eat *a character*, and if it was whitespace go on eating
whitespace, and if it was a printable go straight to only eating
printables.

Fixes #7325.
2020-09-11 20:13:06 +02:00
Fabian Homborg
d688093f7a docs: Update repaint docs
force-repaint now does exactly the same thing as repaint and repaints
are no longer coalesced.
2020-09-11 19:38:55 +02:00
Fabian Homborg
30b2dc2b97 Don't enqueue a repaint in the middle of one
This can easily lead to an infinite loop, if a variable handler
triggers a repaint and the variable is set in the prompt, e.g. some of
the git variables.

A simple way to reproduce:

    function fish_mode_prompt
        commandline -f repaint
    end

Repainting executes the mode prompt, which triggers a repaint, which
triggers the mode prompt, ....

So we just set a flag and check it.

Fixes #7324.
2020-09-11 19:23:26 +02:00
Fabian Homborg
c6cdc06a5b docs: Reword random
Don't SCREAMCAPS random, the command is `random`.

Also some stuffy verbiage.

[ci skip]
2020-09-10 20:48:13 +02:00
Fabian Homborg
624d0b7e42 CHANGELOG complete 2020-09-09 20:24:23 +02:00
Fabian Homborg
7dae2b1e07 docs: Improve complete docs
A bit stuffy, some weird bits (I don't think GNU-style long options
can typically be abbreviated, ``true --v`` and ``bash --hel`` don't work).
2020-09-09 20:23:15 +02:00
Fabian Homborg
900a3c4049 complete: Remove removed options from the docs
These have been removed for ages, the complete docs are too verbose as
it is.
2020-09-09 20:23:15 +02:00
Fabian Homborg
903b7888d3 complete: Make -c optional
Currently, completions have to be specified like

```fish
complete -c foo -l opt
```

while

```fish
complete foo -l opt
```

just complains about there being too many arguments.

That's kinda useless, so we just assume if there is one left-over
argument that it's meant to be the command.

Theoretically we could also use *all* the arguments as commands to
complete, but that seems unlikely to be what the user wants.

(I don't think multi-command completions really happen)
2020-09-09 20:23:08 +02:00
Fabian Homborg
a8e237f0f9 Let complete show completions for one command if just given -c
Currently only `complete` will list completions, and it will list all
of them.

That's a bit ridiculous, especially since `complete -c foo` just does nothing.

So just make `complete -c foo` list all the completions for `foo`.
2020-09-09 18:37:39 +02:00
Fabian Homborg
34be1b458a Add fish_command_not_found handler for pacman
Since version 5 (IIRC), pacman has a file database.

This is useful for people who don't have pkgfile, but we still prefer
that because it's much faster - pacman takes a full *second* on my system.
2020-09-09 17:44:25 +02:00
Johannes Altmanninger
de9874e4de Remove some useless casts
I think the warnings from -Wuseless-cast are mostly platform-specific but
I hope these are correct.
2020-09-08 22:44:03 +02:00
Johannes Altmanninger
fbaa5d193d Declare functions in headers or use internal linkage (static)
Found with gcc's -Wmissing-declarations which gives warnings like

	../src/tinyexpr.cpp:61:5: warning: no previous declaration for ‘int get_arity(int)’ [-Wmissing-declarations]
	   61 | int get_arity(const int type) {

The same warnings show up for builtin functions like builtin_bg because they
currently don't include their own headers. I left that.
Also reformat the touched files.
2020-09-08 22:44:03 +02:00
Johannes Altmanninger
7a4fece445 Give reader control of all edits to a command line
So we can do something on every edit, for example repaint the pager (#7318).
This patch fixes pager refiltering and repainting when pressing Control+U
after typing something in the search field.

Implement this by moving the convenience functions from editable_line_t to
the reader, so we have fewer places where we need to refilter.  Essentially we
only have two cases: insertions at the cursor are handled by insert_string(),
and all others go through push_edit().  This should also make it clearer
where we update undo_history.may_coalesce.

This commit was on the history-search-edit-needle branch, so it should
work fine.  I hope it does play well with some recent changes.

In 6d339df61 (Factor repainting decions from readline commands better
in the reader), insert_string() was simplified a lot, mirror that.

The tests for editable_line_t are not that useful anymore since the caller has
to decide whether to coalesce insertions, but I guess they don't hurt either.
We should have more tests for some interactive scenarios like undo and the
pager filtering.
2020-09-08 22:00:48 +02:00
Mahmoud Al-Qudsi
90433f6ea3 Minimize AST node vector reallocations
Closes #7201
2020-09-08 11:55:10 -05:00
oui-ui
0f674435a3 correct description of -a param regarding _(\w*)
removed the word "not" to resolve an (unintended) negation of negation.
2020-09-08 18:02:50 +02:00
Fabian Homborg
f67673de71 Repaint on pager search
This was broken in 6d339df612, when we removed
the normal repainting logic.

The pager *search* however needs to trigger a refilter, and therefore
needs to trigger after every insert/removal.

Fixes #7318
2020-09-08 15:01:22 +02:00
Mahmoud Al-Qudsi
f88106ef96 [travis] Remove root sudo YAML property
Travis has been complaining that the root `sudo` key is deprecated and
no longer has any effect.
2020-09-07 20:59:42 -05:00
Mahmoud Al-Qudsi
be1604fe31 fixup! Add str2wcs optimization for ascii-only inputs
Fix aligned read past end of buffer.
2020-09-07 20:39:49 -05:00
Mahmoud Al-Qudsi
84c72f2817 Add str2wcs optimization for ascii-only inputs
This avoids the heavy hit of __gconv_transform_utf8_internal.

In the worst case, after `is_ascii` returns the string is guaranteed to
be in the CPU cache (assuming realistic input sizes). In the best (and
hopefully extremely common) case, the conversion table lookups are
completely avoided.

In terms of real world gains, simply calling `history` is anywhere from
2x to 3x faster for large history files composed of mostly ascii
content under glibc 2.31 on AMD64.
2020-09-07 19:38:06 -05:00
Mahmoud Al-Qudsi
1365379518 Optimize away a str2wcs_internal check
str2wcs_internal is one of worst hot paths in the codebase, and this
particular check can be optimized away for non-macOS hosts at compile
time.
2020-09-07 18:05:18 -05:00
Mahmoud Al-Qudsi
bf31333622 [ffmpeg] Prevent -codec from matching -codec:[vas]
This was preventing the narrowing of matching completions.

[ci skip]
2020-09-07 16:52:47 -05:00
Mahmoud Al-Qudsi
2a4289dcd1 [ffmpeg] Fix variable name in __fish_ffmpeg_complete_regex
[ci skip]
2020-09-07 16:52:47 -05:00
Joost-Wim Boekesteijn
0cec12c6c0 ffprobe completions: show_stream -> show_streams
This should be `show_streams` instead of `show_stream` according to:

31b6b6685e:/doc/ffprobe.texi#l218
2020-09-07 18:52:08 +02:00
Fabian Homborg
576ce5f9f5 Remove __fish_command_not_found_handler
This could lead to an infinite loop (well, stack overflow) because
fish_command_not_found would also be defined to call
__fish_command_not_found_handler.

Since this is for

- missing command errors
- when downgrading

we can just remove it.
2020-09-06 13:50:38 +02:00
Fabian Homborg
58d549e058 CHANGELOG fish_command_not_found
[ci skip]
2020-09-06 11:18:31 +02:00
Fabian Homborg
0131974378 Use OpenSUSE command-not-found via $PATH
We check the full $PATH, so it's not guaranteed that it is in /usr/bin.
2020-09-06 11:15:54 +02:00
Fabian Homborg
fbe56a84c7 tests: Export $TERM
I think this might be causing problems on Github CI.
2020-09-06 11:15:54 +02:00
Fabian Homborg
340de73172 Call "fish_command_not_found" if a command wasn't found
Previously, when a command wasn't found, fish would emit the
"fish_command_not_found" *event*.

This was annoying as it was hard to override (the code ended up
checking for a function called `__fish_command_not_found_handler`
anyway!), the setup was ugly,
and it's useless - there is no use case for multiple command-not-found handlers.

Instead, let's just call a function `fish_command_not_found` if it
exists, or print the default message otherwise.

The event is completely removed, but because a missing event is not an error
(MEISNAE in C++-speak) this isn't an issue.

Note that, for backwards-compatibility, we still keep the default
handler function around even tho the new one is hard-coded in C++.

Also, if we detect a previous handler, the new handler just calls it.

This way, the backwards-compatible way to install a custom handler is:

```fish
function __fish_command_not_found_handler --on-event fish_command_not_found
    # do a little dance, make a little love, get down tonight
end
```

and the new hotness is

```fish
function fish_command_not_found
    # do the thing
end
```

Fixes #7293.
2020-09-06 11:15:54 +02:00
ridiculousfish
d1dab22691 Ensure we don't leak half of a pipe
It was possible though unlikely for make_autoclose_pipes to close only
one side of pipe, if it fails to find a new fd. This would result in an
fd leak. Ensure that doesn't happen.
2020-09-05 13:24:26 -07:00
ridiculousfish
1cef87d790 Use anon semaphores only on Linux
On BSDs, anonymous semaphores are implemented using a file descriptor
which is not marked CLOEXEC, so it gets leaked into child processes.
Use ordinary pipes instead of semaphores everywhere except Linux.

Fixes #7304
2020-09-05 13:04:22 -07:00
ridiculousfish
acb33682a9 Remove some errant 'file' from redirection comment
See #7301
2020-09-05 11:28:43 -07:00
ridiculousfish
abadab5176 Revert "Fix examples in tokenizer comment for redirection"
This reverts commit 66f81a2b4c.
2020-09-05 11:27:48 -07:00
Nathan Lanza
66f81a2b4c Fix examples in tokenizer comment for redirection
Four of these examples were incorrect and didn't perform the stated
behavior in neither bash nor fish. Fix them here.
2020-09-05 11:27:30 -07:00
Aurelio Jargas
d4fe110f23 docs/isatty: Mention default value for FILE DESCRIPTOR
As seen in share/functions/isatty.fish (note the empty string):

    switch "$argv"
        case stdin ''
            set fd 0
2020-09-05 15:54:48 +02:00
Johannes Altmanninger
55bc6a27c6 Make prompts forward compatible with fish 3.1.2 by passing locally exported variable
Commit 5d135d555 (prompts: fix pipestatus for jobs prefixed with "not")
introduced a backwards compatibility hack about adding an optional argument
to __fish_print_pipestatus. This hack would break downgrading to fish 3.1.2
if the user copied the new prompt to their config - they would get a backtrace
on every prompt which is arguably worse than the patch's minor improvement.

This does away with the error trace - old fish just won't show the fancy
new pipestatus on `not true`.

Implemented by passing the last $status as the poor man's kwarg, which works
since 3.1.0 (9b86d5dd1 Export all local exported variables in a new scope).

The prompts don't work with fish 3.0.0 or older; downgrading does not seem
too important in general but I think this patch is an okay simplification.
2020-09-05 09:58:55 +02:00
Johannes Altmanninger
89724f9366 prompts: guard against missing fish_is_root_user
Prevents error spew when running one of these prompt on fish 3.1.2.
2020-09-05 09:48:47 +02:00
Mahmoud Al-Qudsi
4331face4a [vips] Add vips completions
Just a skeleton completion file, but the list of available
actions/completions is at least dynamically generated (there's a lot of
them, they are impossible to remember, and they depend on build
options).

[ci skip]
2020-09-04 21:40:27 -05:00
ridiculousfish
457f95fe52 Mark s_cancellation_signal a relaxed atomic
Thread sanitizer is salty about this even though it's
volatile sig_atomic_t. Make it atomic too.
2020-09-04 16:10:22 -07:00
ridiculousfish
3f3531c819 Ensure we preserve errno in signal handlers 2020-09-04 15:32:29 -07:00
Mahmoud Al-Qudsi
fe6fb23f43 [ffmpeg] Add -f formats completions
[ci skip]
2020-09-04 13:43:26 -05:00
Charles Gould
6fd68d553d Stop initializing fish_color_match, it is no longer used 2020-09-04 19:46:38 +02:00
Charles Gould
5e5b9d75e6 docs: Fix background color for interactive examples
For the few weird code blocks where default highlighting does not work,
we must add the 'highlight' class manually to get matching backgrounds.
This reuses the background color defined in pygments.css.
2020-09-04 19:46:38 +02:00