Commit Graph

14139 Commits

Author SHA1 Message Date
Fabian Homborg
c95a223f5e Better errors when calling a command in a command substitution fails 2021-04-19 16:47:17 +02:00
Fabian Homborg
04f1254c94 Disable tmux tests for now
These are just broken at the moment
2021-04-19 16:46:50 +02:00
ridiculousfish
e8a6d31aea Correct behavior of string match and unmatched capture groups
string match is documented as setting an unset variable if a capture group
is unmatched in an otherwise matched regex, and if the `--all` flag is not
provided. However prior to this fix, it instead set a variable containing
the empty string as a single value. Correct the implementation to match
the documentation.

Note that if the `--all` flag is provided we continue to set empty
strings, which is documented.
2021-04-18 21:04:25 -07:00
ridiculousfish
1aa8200b96 Minor cleanup of builtin_string regex
Mark some classes as final and remove some unnecessary variables.
Add a test in preparation for the next fix.
2021-04-18 20:39:14 -07:00
ridiculousfish
092168485b Remove wcstring_tok
wcstring_tok was a funky function which was confusing and used only in
one place. Replace it with split_string_tok, which is somewhat simpler.
2021-04-18 14:46:05 -07:00
ridiculousfish
2fb0a703de Simplify rgb_color_t::try_parse_named
This came out of an investigation into making strings immutable.
This code did "lazy" lowercasing but we can simplify it by just
providing our own case-insensitive compare routine, which is good
enough for colors.
2021-04-18 12:11:38 -07:00
Fabian Homborg
0111eafbbc tmux tests: Actually use absolute $XDG paths
Erasing $XDG_CONFIG_HOME here means it falls back on the default,
which is ~/.config/, which means it reads user configuration!
2021-04-18 21:09:48 +02:00
Johannes Altmanninger
6b41227ff4 completions/dnf: minor addition to always show RPM files
See #7928
2021-04-18 13:09:36 +02:00
Josh Leichtung
f99127a158 Fix spelling of wheel in Wildcards docs 2021-04-18 07:47:52 +02:00
ridiculousfish
7a556ec6f2 Additional work on tmux-complete test
This removes the relative XDG paths, which could have potentially
confused tmux, and also starts the window with the correct size
instead of adjusting the size afterwards.
2021-04-17 16:43:28 -07:00
ridiculousfish
f7cef13b9b Partially fix the tmux-complete test
The autosuggestion was creeping in, causing us to sometimes show file-1
and sometimes just file-. Allow the race through a regular expression.
2021-04-17 16:43:28 -07:00
ridiculousfish
467755bf4a Bravely optimize job_reap
job_reap is now called more often. This optimizes it by doing an
early-out if there are no running jobs (common at the prompt) and also
skipping the save/restore status, since by inspection we also save and
restore the status when running event handlers.
2021-04-17 16:43:28 -07:00
ridiculousfish
7c153a8307 Introduce prepare_to_select, fixing job_summary.py
This concerns printing status messages for background jobs which have
stopped or finished. Previously fish would do this from two places:

1. Before running a command (including empty string)
2. If a signal is received during select()

So if the job finishes while fish is doing something else (like running an
event handler) then we would not print status messages until the user hit
return. This caused the job_summary.py test to be flaky.

Fix this by splitting the interrupt handler into two parts: a part that
handles signals (e.g. triggering exit from the reader), and a part that
always runs just before blocking in select(). This second part always
reaps jobs and prints their status messages. This narrows the window for a
job exit to be "missed" before fish blocks in select, and should make the
job_summary.py test more reliable.
2021-04-17 16:43:28 -07:00
ridiculousfish
3684c91ad2 Make input_event_queue_t a base class
This concerns the problem of "injecting" fancy fish bits like job reaping
into the "common" input stuff which is also used by fish_key_reader.
Instead of providing a callback, make the input event queue a base class
with virtual functions. This allows for a richer interface and simplifies
some memory management issues.
2021-04-17 16:43:28 -07:00
ridiculousfish
939aba02de Refactor input_common.cpp:readb
readb is used to read a single byte from stdin, or maybe update universal
variables, or maybe invoke completion handlers, etc. Previously it
returned char_event_t but this is more complex than necessary; instead we
can just have it return a single byte, or one of a few special error
codes. This makes the readb's role more clear.
2021-04-17 16:43:28 -07:00
ridiculousfish
78147abe8a Switch the interrupt handler from a global to an instance variable
"The" interrupt handler is used when we get a signal while waiting at the
prompt. Switch it from a global function pointer to an std::function. This
is a mild refactoring which itself will be replaced soon.
2021-04-17 16:43:28 -07:00
ridiculousfish
060ce4f7da Remove timeout input events
Now that timeouts are stored in the event queue peeker, we can remove the
notion of timeout events altogether. Instead you may ask for an event with
a timeout, and get back none on timeout. This simplifies how input events
work.
2021-04-17 16:43:28 -07:00
ridiculousfish
bd72791340 Use event_queue_peeker_t when matching key bindings
Previously, when attempting to match a key binding, we would dequeue
events from the queue and put them back on if the binding fails. The
tricky part is timeouts: distinguishing between an escaped character and
the escape key itself. This was handled with "timeout events" and we had
to be careful to know when to discard them.

Switch to a new model: use event_queue_peeker more pervasively.
Temporarily dequeued events are stored in the peeker, and the peeker
itself remembers when it has seen a timeout. This is in preparation for
removing the idea of "timeout events" altogether.
2021-04-17 16:43:27 -07:00
ridiculousfish
c570a14c04 Simplify event_queue_peeker_t
Make it an ordinary struct wrapping a vector, instead of a template.
This is in preparation for using it more widely, for matching bindings
as well as mouse CSI sequences.
Also add some mouse-disabling tests.
2021-04-17 16:43:27 -07:00
ridiculousfish
e8a61ef4aa Introduce select_wrapper_t
select_wrapper_t wraps up the annoying bits of using select(): keeping
track of the max fd, passing null for boring parameters, and
constructing the timeout. Introduce a wrapper struct for this and
replace the existing uses of select() with the wrapper.
2021-04-17 16:43:27 -07:00
ridiculousfish
0dd24c8f74 Correct nfds argument to select()
In readch_timed, we were passing 1 as the number of fds. This is correct if
the fd is 0 (stdin) which it typically is; however this will fail if in_ is
not stdin. Switch to in_ + 1.
2021-04-17 16:43:27 -07:00
ridiculousfish
48b42c0255 Reorganize input_event_queue_t declaration
This moves the private bits to the bottom. No functional change.
2021-04-17 16:43:27 -07:00
ridiculousfish
3b32a32dda Replace some format_strings with to_string
This is hopefully a little faster and a little safer as there's
no format string involved.
2021-04-17 16:43:27 -07:00
ridiculousfish
be9579418f Refactor to use has_external_proc instead of a manual loop
No functional change here.
2021-04-17 16:43:27 -07:00
ridiculousfish
e299f89db3 Rename print_job_summary to call_job_summary
No functional change; this is simply a less misleading name.
2021-04-17 16:43:27 -07:00
Johannes Altmanninger
db0fe92aaa completions/dnf: cautiously complete RPM files
Complete RPM files instead of pacakges if there is either
1. a slash in the token, which precludes package names
2. no matching package

To enable 2, pass the commandline token to the dnf query, instead of
an undefined variable. This allows SQL injection; not sure if we care.

We could always complete RPM files but maybe that's too noisy.
Also, isn't that what the "rpm" command is for?

Closes #7928
2021-04-17 22:53:34 +02:00
Johannes Altmanninger
75142f0cde Add Dockerfile for Fedora 2021-04-17 22:53:34 +02:00
Johannes Altmanninger
d96a2e7052 Make docker script work when CDPATH is set
Since #3914 we convert empty CDPATH entries to ".", which makes them
easier to use in fish scripts. This has backfired here, because bash's
cd prints the directory if the "." entry from CDPATH is used.
From bash(1) on cd:

> If a non-empty directory name from CDPATH is used, or  if  -  is
> the  first argument, and the directory change is successful, the
> absolute pathname of the new working directory is written to the
> standard output.

My preferred fix would be to convince bash to amend "non-empty
directory" to "non-empty directory other than .".
2021-04-17 22:53:34 +02:00
Johannes Altmanninger
b3c520cc47 README: link to the Building section 2021-04-17 22:53:34 +02:00
Fabian Homborg
4bcecc8983 docs: Make background at least one screen tall
Otherwise this would look ugly by stopping the gradient after the
content, so in e.g. the `end` or `false` page it would leave an ugly stripe at
the bottom.
2021-04-17 17:36:32 +02:00
Fabian Homborg
d9b212f60b docs: Move some more sections from index to language
These aren't a 100% *exact* fit, but they're mostly language features.
2021-04-16 18:06:33 +02:00
Fabian Homborg
8bc7a85a69 docs: Remove #anchor links
Fixes at least one broken link to syntax
2021-04-16 18:06:33 +02:00
Collin Styles
42c11f1b6c Remove completion files for ls aliases; just use function --wraps 2021-04-16 17:40:55 +02:00
Fabian Homborg
5a53ead240 README: Remove rootnroll
This was removed from fish-site in
7c19bf2cc9a3742346527cd6979671f16b8caeb9 because it's out of date, so
it gives a bad first impression.

In my tests it also loads very slowly and features oh-my-fish instead
of a stock fish.
2021-04-16 15:47:18 +02:00
Fabian Homborg
3b87547411 Fix skipping locale tests on Github Actions 2021-04-16 09:01:41 +02:00
239
5e66722452 Update completions for resolvectl 2021-04-15 17:38:26 +02:00
239
4688a84398 Update completions for loginctl 2021-04-15 17:38:26 +02:00
239
9b85254717 Update completions for Keybase 2021-04-15 17:38:26 +02:00
239
975cd13108 Update completions for cryptsetup 2021-04-15 17:38:26 +02:00
Fabian Homborg
fff158fd2b tests: Disable locale.fish on Github Actions
Sometimes hangs with tsan.

Works around #7934.
2021-04-15 17:26:08 +02:00
Fabian Homborg
9850f8d18a docs: Update status docs
`status --current-function` is not a thing.
2021-04-14 21:46:51 +02:00
Fabian Homborg
84087f09d4 webconfig: Remove gigantic padding 2021-04-14 20:49:24 +02:00
Fabian Homborg
7eddf48cfa webconfig: Cleanup running prompts 2021-04-14 19:08:33 +02:00
Fabian Homborg
333032f626 tests: Increase how long exit_nohang tries
This runs in 100ms increments, so there's not a lot of harm in trying
longer - it should take the same time everywhere it succeeded before.

But I've reproduced failures on FreeBSD 13 on sr.ht, so there's at
least one platform where a total time of 1 second isn't enough.

Now we do 50 tries, which is 5 seconds.
2021-04-14 18:55:11 +02:00
Fabian Homborg
ef96a6614b Update termsize before a sigwinch handler
This could have been one iteration off, e.g.

```fish
function on-winch --on-signal winch
    echo $LINES
end
```

Resize the terminal, it'll print e.g.

24

then run `echo $LINES` interactively, it might have a different answer.

This isn't beautiful, but it works. A better solution might be to make
the termsize vars electric and just always update them on read?
2021-04-14 17:27:53 +02:00
David Adam
9db846a5a7 docs: some improvements to the notes on key bindings
Includes acknowledgement that these are not full editors. Closes #4023.
2021-04-14 21:43:14 +08:00
Fabian Homborg
56af5d0702 Revert "git prompt: Show stagedstate without dirtystate"
After further thinking, showing this now, by default, without a nice way to turn it off isn't great.

This reverts commit 573fed7798.
2021-04-13 19:10:04 +02:00
Xirui Zhao
8bbb06bf5c vi mode: bind u/C-r to undo/redo in place of history search (#7908) 2021-04-13 18:47:34 +02:00
Fabian Homborg
5750351210 Update CHANGELOG 2021-04-13 16:58:22 +02:00
Fabian Homborg
4fa17bd512 git prompt: Don't compute bits we don't need 2021-04-13 16:44:46 +02:00