Commit graph

16029 commits

Author SHA1 Message Date
Christopher Phillips
aba62c2211 add safe $PATH lookup; update powershell regex 2022-08-08 20:58:48 +02:00
Christopher Phillips
6e6085a623 Update -z statement to remove close paren error 2022-08-08 20:58:48 +02:00
Christopher Phillips
d20554e343 Revert -z statement in help.fish
A recent commit added an invalid expression to the help.fish script. The
"-z" flag caused the error: "test: Missing close paren at index 11"
2022-08-08 20:58:48 +02:00
Christopher Phillips
8e3e50f9ee Add powershell support to suppress UNC path error
Prefer using powershell.exe over cmd.exe on wsl to supress terminal error:
"CMD.EXE was started with the above path as the current directory"
2022-08-08 20:58:48 +02:00
database64128
f6e3f4db34 cp completions: reflink's arguments are optional
When no arguments are unspecified, `--reflink` is equivalent to `--reflink=always`.
2022-08-08 10:18:40 +02:00
ridiculousfish
e0a4d49ef3 Bravely stop appending a newline in reader_shell_test
This newline apparently dates back to when we required all statements to
be terminated; but our AST no longer requires that so we can remove
this. No functional change expected here.
2022-08-07 14:03:33 -07:00
ridiculousfish
1dff1cb2c4 Factor out handling of readline_cmd_t::execute
This reduces the size of handle_readline_command.
No functional change.
2022-08-07 13:37:56 -07:00
Johannes Altmanninger
7fb4b7c8bd prompt_pwd: stop clobbering global/universal fish_prompt_pwd_full_dirs
Closes #9123
2022-08-07 20:24:51 +02:00
ridiculousfish
deec78cdd3 cmake: Unset GIT_WORK_TREE and GIT_DIR before FetchContent_Populate
GIT_WORK_TREE is an environment variable which tells git where the
worktree is. It may be set by the user or by git itself, e.g. when
running `git rebase -i --exec ...`. If it is set, it overrides the
working directory, causing the `git checkout` from FetchContent_Populate
to fail. Clear this variable.

Do the same for GIT_DIR for the same reason.

A way to reproduce the failure that this commit fixes is:

    git rebase -i HEAD^^^ --exec 'ninja -C /path/to/build/dir fish'

prior to this commit, using the fetched PCRE2, this would fail in CMake.
2022-08-06 13:07:22 -07:00
Fabian Boehm
39fbc27d8d Clarify math documentation
The words "rounded down" here get us into some trouble.
2022-08-06 10:58:46 +02:00
SeekingBlues
f9786673e3 Fix typo for or input function 2022-08-05 18:32:32 +02:00
Fabian Boehm
0f3e58efe7 Update littlecheck to e2f243e80117aad27adfb8da73f4901c88b3af6d
Now prints a message if process was killed by a signal, truncates
output if no more checks were found, has an option to force color.
2022-08-05 18:29:29 +02:00
Michael Nickerson
b08a962edb Fix compile error on OpenBSD 2022-08-04 08:13:19 +02:00
Aaron Gyes
d1f08d4944 Revert "vagrant completions: use __fish_parent_directories"
This reverts commit 7c1b68516d.
2022-08-03 00:34:32 -07:00
Aaron Gyes
7c1b68516d vagrant completions: use __fish_parent_directories 2022-08-02 22:31:23 -07:00
Fabian Boehm
177cfbc605 docs/path: Add some more on resolve/normalize dichotomy 2022-08-02 19:58:43 +02:00
Aaron Gyes
e45b3abab2 test -z 2022-08-02 00:54:38 -07:00
Aaron Gyes
ff2999ef2b Three more of the same test -z thing. 2022-08-02 00:42:37 -07:00
Aaron Gyes
b9590d04e7 fish_toggle_commandline: minor test cleanup 2022-08-02 00:30:06 -07:00
Aaron Gyes
df51fea897 git completion: use new test -ef
Just an opportunistic little cleanup. Technically faster.
2022-08-02 00:15:50 -07:00
Johannes Altmanninger
095c093af6 Fix "commandline --paging-mode" false negative when there is no room for pager, attempt 2
The previous fix was reverted because it broke another scenario.  Add tests
for both scenarios.

The first test exposes another problem: autosuggestions are sometimes not
recomputed after selecting the first completion with Tab Tab. Fix that too.
2022-07-31 07:14:56 +02:00
Aaron Gyes
7b18a70724 Revert "Fix "commandline --paging-mode" false negative when there is no room for pager"
This reverts commit 1edcd8ab29.

The commit broke hitting <TAB> to show the pager, followed by
down-or-search.
2022-07-30 18:15:10 -07:00
Johannes Altmanninger
88d1317eaa completions/git: forward a ./-prefix from the command line
"git add ./" shows only hidden files (if at all). It should show all files
that can be added.
The problem is that candidates come from "git status" which prints clean
relative paths. Let's allow some unclean paths.

This is far from a complete fix but it should work for the common scenario.

Observe that wildcard_complete_internal() actually filters out all non-hidden
files, if the query is `./`.

Closes #9091
2022-07-31 00:14:51 +02:00
Johannes Altmanninger
a447cc38a9 Hint at more matches at the bottom of the history pager 2022-07-30 23:27:24 +02:00
Johannes Altmanninger
1af9b8e430 Prefix history pager results with a fake prompt
This makes it easy to see where the individual commands start.  Perhaps we
can get rid of this once we have syntax highlighting for the commands in
the history pager, or if we add timestamps as descriptions.
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
453aac14af Advance pager history search with Control-R/Control-S
Note that every change to the search field still starts a new search, from
the end of history. We could change this in future but it's unclear to me
what the expected behavior is. I don't find the traditional readline behavior
very intuitive.
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
24e04daa22 Teach history search to move forward in time
Will use this for forward incremental search.

No functional change.
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
dcff0a2f2b Add Control+R incremental history search in pager
This reimplements ridiculousfish/control_r which is a more future-proof
approach than #6686.
Pressing Control+R shows history in our pager and allows to search filter
commands with the pager search field.

On the surface, this works just like in other shells; though there are
some differences.

- Our pager shows multiple results at a time.
- Other shells allow to use up arrow/down arrow to select adjacent entries
  in history. Shouldn't be hard to implement but the hidden state might
  confuse users and it doesn't play well with up-or-search, so this is
  left out.

Users might expect the history pager to use subsequence matching (fuzzy
matching) like the completion pager, however due to the history pager design it
uses substring matching.  We could change this in future, however that means
we would also want to change the ordering from "reverse-chronological" to
"longest common subsequence" (e.g. what fuzzy finders do), because otherwise
a query "fis" might give this ordering:

            fsck /dev/disk/by-partlabel/Linux\x20filesystem
            fish

which is probably not what the user wants.

The pager shows only a small number of history items at a time.  This is
because, as explained above, the history pager does not support subsequence
matching, so navigating it does not scale well.

Closes #602
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
b0233c9aa7 Revert "Refactor: inline clear_pager()"
The next patch wants to add state that should be reset when we clear the
pager, which will happen in this function.

This reverts commit b25b291d38.

No functional change.
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
9a0d8e67df Extract function for smartcase history search
To be used in the commit after next.

No functional change.
2022-07-30 23:27:24 +02:00
Johannes Altmanninger
3954200555 Centralize how we invalidate pager rendering after completions change
The pager's rendering_needs_update() function detects some but not all
scenarios where a rendering is stale. In particular, it does not compare
the completion strings.

To make this work, we manually invalidate the pager rendering whenever we
update completion strings. The history pager needs the same functionality,
so let's move it into the pager.

No functional change.
2022-07-30 23:27:24 +02:00
ridiculousfish
2410e27d10 Add a test and CHANGELOG fix for #9096 2022-07-30 10:14:19 -07:00
Baspar
ec8fd628bd Generate job & process exit events for background jobs 2022-07-30 10:06:33 -07:00
Michael Forster
91c68ec1af Add fish_cursor_selection_mode documentation 2022-07-30 09:49:23 -07:00
Michael Forster
6003edfb42 Add test for the default cursor selection mode
Also add documentation for the tests
2022-07-30 09:49:07 -07:00
Michael Forster
ef9994d55a Don't use Python f-strings in tests 2022-07-30 09:49:07 -07:00
Michael Forster
f09d2c4e6e Use env_dispatch to update cursor selection mode 2022-07-30 09:49:07 -07:00
Michael Forster
7d198fa404 Add an initial test for fish_cursor_selection_mode 2022-07-30 09:49:07 -07:00
Michael Forster
5cf67c2d61 Use dedicated variable to configure selection size
This addresses code review feedback to not couple the purely visual
concept of cursor style with the logical concept of the selection size.
Instead this now uses a dedicated variable
`$fish_select_char_after_cursor` to determine whether to extend the
selection beyond the cursor:

* fish_select_char_after_cursor = 1 or unset -> extend selection
* all other cases -> place the selection end that the cursor
2022-07-30 09:49:07 -07:00
Michael Forster
a7d943793e Consider cursor width when updating selection
This fixes the handling of the right end of the selection. Currently the
right end is considered to be at the cursor position + 1. When using a
`block` or `underline` cursor this is arguably correct, because the
cursor has a width of 1 and spans from the current position to the next:
```
    x x [x x x̲] x
```

This is incorrect though (or at least very unintuitive), when using a
`line` cursor:
```
    x x [x x|x] x
```

This commit changes the strategy for determining the end of the
selection in the following way:

* If the current cursor as determined by `$fish_cursor_<bind_mode>` is
  set to `line`, then a cursor width of `0` is assumed.
* In all other cases, including `block` and `underscore` as well as when
  no value is set we retain the previous behavior of assuming a cursor
  width of `1`.
```
    x x [x x x̲] x
    x x [x x|]x x
```

This change should not affect many users, because the selection is
probably used most by vi-mode users, who are also likely to use a
block cursor.
2022-07-30 09:49:07 -07:00
Johannes Altmanninger
1edcd8ab29 Fix "commandline --paging-mode" false negative when there is no room for pager
The pager still works even if there is no room to render it.  So let's make
"commandline --paging-mode" return true if there is an off-screen pager.

This fixes the problem with the upcoming history-pager described in
https://github.com/fish-shell/fish-shell/pull/9089#issuecomment-1196945456
2022-07-28 22:08:33 +02:00
Johannes Altmanninger
a584fc51d9 Explain edge case in select_completion_in_direction()
No functional change.
2022-07-28 10:41:00 +02:00
Johannes Altmanninger
1fc3d51dde Fix misleading comment in set_buffer_maintaining_pager()
This function used to clear the pager search field but it no longer does.

No functional change.
2022-07-28 10:40:54 +02:00
Johannes Altmanninger
2e8ecfdb44 Clarify escaping of ASCII control characters
We use "c > 0" but we actually mean "c != 0".  The former looks like the
other code path handles negative c.  Yet if c is negative, our code would
print a single escaped byte (\xXY) which is wrong because a negative value
has "sizeof wchar_t" bytes which is at least 2.

I think on platforms with 16-bit wchar_t it's possible that we actually
get a negative value but I haven't checked.
2022-07-27 11:24:35 +02:00
Johannes Altmanninger
f1b4366222 Consolidate logic in escape_string_script()
No functional change.
2022-07-27 11:24:35 +02:00
Johannes Altmanninger
83893558f9 Make ESCAPE_NO_PRINTABLES behavior a bit less weird
Since the fix for #3892, this escaping style escapes

	\n to \\n

as well as

	\\ to \\\\
	\' to \\'

I believe these two are the only printable characters that are escaped with
ESCAPE_NO_PRINTABLES.
The rationale is probably to keep the encoding unambiguous and reversible.
However that doesn't justify escaping the single quote. Probably this was
an accident, so let's revert that part.

This has the nice effect that single quotes will no longer be escaped
when rendered in the completion pager (which is consistent with other
special characters). Try it:

    complete : -a "aaa\'\; aaaa\'\;" -f

Also this makes the error output of builtin bind consistent:

    $ bind -e --preset \;
    $ bind -e --preset \'
    $ bind \;
    bind: No binding found for sequence “;”
    $ bind \'
    bind: No binding found for sequence “'”

the last line is clearly better than the old version:

    bind: No binding found for sequence “\'”

In general, the fact that ESCAPE_NO_PRINTABLES escapes the (printable)
backslash is weird but I guess it's fine because it looks more consistent to
users, even though the result is an undocumented subset of the fish language.
2022-07-27 11:24:35 +02:00
Johannes Altmanninger
8729623cec Make ESCAPE_ALL the default and call its inverse ESCAPE_NO_PRINTABLES
ESCAPE_ALL is not really a helpful name. Also it's the most common flag.
Let's make it the default so we can remove this unhelpful name.

While at it, let's add a default value for the flags argument, which helps
most callers.

The absence of ESCAPE_ALL makes it only escape nonprintable characters
(with some exceptions). We use this for displaying strings in the completion
pager as well as for the human-readable output of "set", "set -S", "bind"
and "functions".

No functional change.
2022-07-27 11:24:35 +02:00
Johannes Altmanninger
e5d5391687 Remove useless escaping of variable names
When listing variables, "set" tries to escape variable names.
Since variable names cannot have special characters, this doesn't do anything.

The escaping is one of the few places that does not use ESCAPE_ALL.  This has
complex behavior; let's alleviate the problem by getting rid of this call.

No functional change.
2022-07-27 11:24:35 +02:00
Johannes Altmanninger
3f90efca38 clang-format C++ files
Or should we stop using it?

I'm fine with either always or never using auto-formatting but our current
way of using it only sometimes is confusing.

No functional change.
2022-07-27 10:05:41 +02:00
Shun Sakai
13febcf54f
Add zig completion (#9083)
* Add `zig` completion

* Update CHANGELOG

* Update `zig` completion

* Fix `zig` completion

Change to enable filename completion on `zig cc` and `zig c++`.
2022-07-26 16:01:46 +02:00