Commit graph

13042 commits

Author SHA1 Message Date
Johannes Altmanninger
46746b4b26 completions/git: offer commit ranges for range-diff
A match made in heaven!
2020-09-27 21:59:15 +02:00
ridiculousfish
1390112b46 Suppress linker warnings in Mac debug builds
fish wants to build with -mmacosx-version-min=10.9. This is important
because it ensures that we do not use functions or linker features which
which are not available on 10.9. However this collides with the fact
that fish also prefers to use a pcre2 package installed on the system,
which is typically built for that system.

Mac ld will (rightly) complain when it sees a 10.9-targeted binary
linking a 10.15-targeted dylib. This is an annoying warning that gets
emitted on every build.

We could fix this either having Mac builds prefer the vendored PCRE2
by default, or by having debug builds target the system version. But
we want to continue to default to system PCRE2 and we don't want to risk
losing compatibility with older Mac versions. So we will just suppress
all linker warnings in Mac debug builds.
2020-09-27 11:35:16 -07:00
Johannes Altmanninger
e8859b4ce2 Do not treat newlines special in bigword movements
Improves on #7328.

I believe this is the correct behavior, simply skip all whitespace before
a word. Try with

	./fish -C 'bind \ef forward-bigword; bind \eb backward-bigword; bind \ed kill-bigword; bind \cw backward-kill-bigword'

Also unrelated formatting fixes. I don't think a CI failure on unformatted
code is warranted but I wish it could do that behind the scenes.
2020-09-27 18:04:09 +02:00
Johannes Altmanninger
791d23502f Do not add a space after completing flag with optional argument
For example "grep --color"<TAB> can complete to "grep --color=".  Don't add
a space in this case; we do the same for arguments that end in =.

In GNU-style getopt, equal sign means that the flag has an argument. Without
the = it would not consume the next argument as opposed to Python's argparse.
2020-09-27 17:56:21 +02:00
David Adam
9f1fc6d040 CHANGELOG: work on 3.2.0
[ci skip]
2020-09-27 22:37:18 +08:00
sgrj
ab2cb03189
Consistency-fix for word motions (#7354)
* change word motion test to include start cursor in specification

* add test case for bug

* fix bug
2020-09-27 15:34:34 +02:00
Fabian Homborg
adb1f993a7 Reader: Turn *off* INLCR for external commands
That's how it worked previously, and it makes ctrl-j usable again.

Fixes #7352
2020-09-27 13:54:47 +02:00
Fabian Homborg
0f7e2ca99c Don't put commandline on a new line if prompt is "long"
This was a weird special behavior where we'd put the commandline on a
new line if it wrapped *and* the prompt was > 33% of the screen.

It seems to be more confusing than anything.

Fixes #5118.
2020-09-27 13:12:06 +02:00
Fabian Homborg
689e96263e tests: Add yet another sleep 2020-09-27 09:22:45 +02:00
David Adam
73173dce7a CHANGELOG: work on 3.2.0
[ci skip]
2020-09-27 10:54:15 +08:00
ridiculousfish
e88eb508d0 Rework variable assignments during tab completion
Prior to this change, tab completing with a variable assignment like
`VAR=val cmd<tab>` would parse out and apply VAR=val, then recursively
invoke completions. This caused some awkwardness around the wrap chain -
if a wrapped command had a variable completion we risked infinite
recursion. A secondary problem is that we would run any command
substitutions inside variable assignment, which the user does not expect
to run until pressing enter.

With this change, we explicitly track variable assignments encountered
during tab completion, including both those explicitly given on the
command line and those found during wrap chain walk. We then apply them
while suppressing command substitutions.
2020-09-26 18:39:38 -07:00
ridiculousfish
cc07716dc1 Separate out variable assignments when completing
In preparation for applying variable assignments (VAR=VAL cmd), separate
them out from the command when performing completions. This includes both
those that the user typed, and any that come about through
completion --wraps.
2020-09-26 17:30:25 -07:00
ridiculousfish
3ef83de866 Rename cmd to cmdline in completer_t::perform_for_command
This makes it clear that the commandline contains arguments, etc.
2020-09-26 17:30:13 -07:00
ridiculousfish
757dda43ac Factor custom completion information into custom_arg_data_t
When completing and walking a wrap chain, we pass around a lot of
information. Factor this together into a new struct custom_arg_data_t
which reduces the number of parameters needed.
2020-09-26 17:30:10 -07:00
ridiculousfish
5cadea0173 Migrate the complete_custom transient command line pop to cleanup_t
This ensures that it gets cleaned up even if there is a mid-function
return.
2020-09-26 17:25:02 -07:00
ridiculousfish
45b85d28bb Completion wrap chain visited set to store only wrapped command
The "wrap chain" refers to a sequence of commands which wrap other
commands, for completion purposes. One possibility is that a wrap chain
will produce a combinatorial explosion or even an infinite loop, so there
needs to be logic to prevent that. Part of that logic is encapsulated in a
visited set (wrap_chain_visited_set_t) to prevent exploring the same item
twice.

Prior to this change, we stored pairs (command, wrapped_command). But we
only really need to store the wrapped command. Switch to that.

One consequence is that if a command wraps another command in more than
one way, we won't explore both ways. This seems unlikely in practice.
2020-09-26 17:24:59 -07:00
Fabian Homborg
f708632ca3 tests: Remove test for windows line ending message
This is flaky on launchpad for some reason, and it's really not
important enough to hold it up.

So let's just leave this untested.
2020-09-26 15:19:24 +02:00
Fabian Homborg
caccc0cddb Add more tests for -c arguments 2020-09-26 15:19:24 +02:00
Johannes Altmanninger
879e80859c Refactor: apply some lints
And reformat touched files; my editor just does that.
2020-09-26 14:56:03 +02:00
Johannes Altmanninger
45e7c709f4 Consolidate complete cycle detection and always report error on cycle
Detect recursive calls to builtin complete and the internal completion in
the same place.

In 0a0149cc2 (Prevent infinite recursion when completion wraps variable assignment)
we don't print an error when completing certain aliases like:

	alias vim "A=B vim"

But we also gave no completions.
We could make this case work, but I think that trying to salvage situations
like this one is way too complex. Instead, let the user know by printing an
error. Not sure if the style of the error fits.

We could add some heuristic to alias to not add --wraps in some cyclic cases.
2020-09-26 14:56:03 +02:00
Johannes Altmanninger
3dd9531472 Refactor: decouple the command to complete from completer_t
This allows us to reuse a completer_t for completions of commands like
"a=b ... ", instead of calling complete().
2020-09-26 14:56:03 +02:00
Johannes Altmanninger
e4e2155f5e Refactor: move wrap chain visitor into a function
The lambda has grown way too big, and it was not easy to see what the inputs
and outputs are. We always use the same visitor, so the function parameter
is not necessary.
2020-09-26 14:56:03 +02:00
Johannes Altmanninger
f415b3b551 Update littlecheck
4a3e4c8 Allow inline #CHECK directives and ignore double-commented directives
2020-09-26 14:56:03 +02:00
Fabian Homborg
fa0c9f90f8 Read arguments with fish -c
This reads any additional positional arguments given to `fish -c` into
$argv.

We don't handle the first argument specially (as `$0`) as that's confusing and
doesn't seem very useful.

Fixes #2314.
2020-09-26 14:47:20 +02:00
Fabian Homborg
396d7e105f fish_tests: Break if unescape test failed
Otherwise this prints millions of lines of errors, which just seems
like overkill
2020-09-26 10:43:05 +02:00
Fabian Homborg
06f6436943 reader: Return true if suppress-autosuggestion suppressed
This allows

bind -k backspace suppress-autosuggestion or backward-delete-char

To remove the suggestion on the first press and then delete
chars.

Note: This requires that we then don't reenable suggestions
immediately afterwards. Currently we don't after deletion.

Fixes #1419.
2020-09-26 10:09:55 +02:00
Fabian Homborg
537b3f6cb1 tests/exec: Wait after writing to a file before executing it
Otherwise we might get "text file is busy", or worse no error at all.

Hoping .2 seconds is enough here.
2020-09-26 07:22:17 +02:00
Johannes Altmanninger
e9582c41b2 Remove __fish_complete_external_command
It's no longer used.
2020-09-25 19:33:01 +02:00
Johannes Altmanninger
618705285d completions/git: support ... range notation
https://git-scm.com/docs/gitrevisions#_revision_range_summary
2020-09-25 19:33:01 +02:00
Johannes Altmanninger
2a95b283ee completions/git: complete only right commit if cursor is beyond the ".."
This enables completion for the right part of a range in many cases, like
`git log HEAD~10..`.
2020-09-25 19:33:01 +02:00
Johannes Altmanninger
16ae532368 Fix typos in docs 2020-09-25 19:33:01 +02:00
Fabian Homborg
0d0ee473fa Detect windows line endings when executing a file
Fixes #2783.
2020-09-25 16:51:05 +02:00
Fabian Homborg
d636918795 Fix warnings in CHANGELOG
../CHANGELOG.rst:30: WARNING: Bullet list ends without a blank line; unexpected unindent.
../CHANGELOG.rst:117: WARNING: Inline literal start-string without end-string.

[ci skip]
2020-09-24 21:03:47 +02:00
Fabian Homborg
293a3a628d Remove pipestatus_with_signal
This was a wrapper around status_to_signal, just because that only
handled a single argument.

Instead, just teach status_to_signal to handle multiple arguments and
be done.
2020-09-24 20:14:10 +02:00
Fabian Homborg
dde8318e50 print_pipestatus: Simplify
Just some minor stylistic nits
2020-09-24 20:08:16 +02:00
Fabian Homborg
a776b08e84 Use bools, we have the technology 2020-09-24 18:53:19 +02:00
David Adam
4cb9f3224c CHANGELOG: work on 3.2.0
[ci skip]
2020-09-24 22:50:57 +08:00
Fabian Homborg
7cac8886bf docs: Some more on argument handling
Reword and expand the list section, and add another explicitly on
argument handling.

Fixes #4630

[ci skip]
2020-09-23 18:48:05 +02:00
Fabian Homborg
c1912e5624 docs: Change hybrid_binding function name
Just "hybrid_bindings" won't trigger the mode prompt.

(yes, this is cheesy)

[ci skip]
2020-09-23 18:15:53 +02:00
Fabian Homborg
1188a12dfd type: Print *only* the path if given --path or --force-path
This is what happens when you check your tests in the wrong tab,
folks.

Fixes #7345.
2020-09-23 17:24:51 +02:00
Mahmoud Al-Qudsi
533957fc2e [apt] Add --with-new-pkgs completion
[ci skip]
2020-09-22 21:52:47 -05:00
Fabian Homborg
8008dfda1e Reorder FAQ
Try to keep related things together - first the variable questions,
then the prompt questions, then more customization, then syntax
incompatibilities, ...

I'm not convinced all of these are actually frequently asked, or that
all frequently asked questions are here, but that's for later.

[ci skip]
2020-09-22 17:34:42 +02:00
Fabian Homborg
1da56f9937 Make history search smartcase
This makes history searches case-insensitive, unless the search string
contains an uppercase character.

This is what vim calls "smartcase".

Fixes #7273.
2020-09-22 16:13:24 +02:00
Johannes Altmanninger
0a0149cc2a Prevent infinite recursion when completion wraps variable assignment
Closes #7344

Apply a targeted fix to the place where complete() is called to handle nested
variable assignments.  Sadly, reporting an error is probably not okay here,
because people might legitimately use aliases like:

	alias vim "A=B command vim"

This is all a bit ugly, and I hope to find a cleaner solution.  Supporting
completions on commandlines like `x=$PWD cd $x/ ` is a nice feature but it
comes with some complexity.
2020-09-22 01:11:18 +02:00
Johannes Altmanninger
ca538fa8d8 Refactor: make function static and reformat
"IndentCaseLabels: false" seems nice but not now.
2020-09-22 00:17:19 +02:00
Mahmoud Al-Qudsi
383f1d1a19 fixup! Make type a builtin
[ci skip]
2020-09-21 15:42:55 -05:00
Fabian Homborg
c7b51b360d CHANGELOG
[ci skip]
2020-09-21 21:01:44 +02:00
Fabian Homborg
796d92b4e9 benchmark driver: Allow passing a second fish path to compare
[ci skip]
2020-09-21 20:58:39 +02:00
Fabian Homborg
ef9c924960 Make type a builtin
This is too important to not be one.

For one if it couldn't be loaded for any reason it would
break a lot of fish scripts.

Also this is faster by ~20x.

Fixes #7342
2020-09-21 20:58:34 +02:00
Fabian Homborg
7934972751 Add some more type tests 2020-09-21 17:45:15 +02:00