Commit graph

14507 commits

Author SHA1 Message Date
Fabian Homborg
80888eed57 Remove read_only stuff from env_var_t
This doesn't work.

The real thing that tells if something is read-only is
electric_var_t::readonly().

This wasn't used, and we provide no way to make a variable read-only,
which makes this an unnecessary footgun.
2021-07-30 15:33:08 +02:00
Fabian Homborg
dd3cdbcfc9 Fix crash if $PWD is used as for-loop variable
for PWD in foo; true; end

prints:

>..src/parse_execution.cpp:461: end_execution_reason_t parse_execution_context_t::run_for_statement(const ast::for_header_t&, const ast::job_list_t&): Assertion `retval == ENV_OK' failed.

because this used the wrong way to see if something is read-only.
2021-07-30 15:33:04 +02:00
Fabian Homborg
55732f445a set: Use env_var_t::flags_for() to see if it's read-only
env_var_t::read_only() is basically broken.

It doesn't work for $PWD, as best as I can tell no variable is
read-only except for a hardcoded list of some of the electric ones.

So we should probably remove the entire read_only and
setting_read_only mechanism.
2021-07-30 15:32:58 +02:00
Fabian Homborg
09b8471f5c Test numeric locale
This allows us to test that `test` takes numbers with decimal point even in comma-using locales,
to stop those pesky americans from breaking everything again.

(and yes, we use french to keep myself honest)
2021-07-29 17:20:20 +02:00
Fabian Homborg
4c90ed0e0d Generate french locale
To keep myself honest, we're not gonna choose german
2021-07-29 17:20:20 +02:00
Fabian Homborg
bf1fd733d0 Revert "Extend the fast path of fish_wcstod"
This breaks in comma-using locales (like my own de_DE.UTF-8), because
it still uses the locale-dependent strtod, which will then refuse to
read

   1234.567

Using strtod_l (not in POSIX, I think?) might help, but might also be
a lot slower. Let's revert this for now and figure out if that is
workable.

This reverts commit fba86fb821.
2021-07-29 16:29:12 +02:00
ridiculousfish
fba86fb821 Extend the fast path of fish_wcstod
fish_wcstod had a "fast path" which looked for all digits, otherwise
falling back to wcstod_l. However we now pass the C locale to wcstod_l,
so it is safe to extend the fast path to all ASCII characters.

In practice math parsing would pass strings here like "123 + 456" and
the space and + were knocking us off the fast path. benchmarks/math.fish
goes from 2.3 to 1.4 seconds with this change.
2021-07-28 16:14:55 -07:00
ridiculousfish
32e23c84f4 Clean up parser_t::push_block
Fix some unnecessary copying and unused variables.
2021-07-28 15:37:34 -07:00
ridiculousfish
789261a40c Stop storing is_breakpoint inside the parser
This can also be trivially computed from the block list.
2021-07-28 13:56:33 -07:00
ridiculousfish
b914c94cc1 Stop storing 'is_block' inside the parser
is_block is a field which supports 'status is-block', and also controls
whether notifications get posted. However there is no reason to store
this as a distinct field since it is trivially computed from the block
list. Stop storing it. No functional changes in this commit.
2021-07-28 13:56:33 -07:00
Fabian Homborg
b3cdf4afe1 Hardcode $PWD as read-only for set --show
Through a mechanism I don't entirely understand, $PWD is sometimes
writable (so that `cd` can change it) and sometimes not.

In this case we ended up with it writable, which is wrong.

See #8179.
2021-07-28 22:13:22 +02:00
Fabian Homborg
3db78232c6 Show if a var is read-only with set --show
Fixes #8179.
2021-07-28 21:13:03 +02:00
Kevin Konrad
413fd2fc03 extract argcomplete completion mechanism into its own function 2021-07-28 18:10:59 +02:00
Kevin Konrad
577a273228 add changelog entry for qmk completion 2021-07-28 18:10:59 +02:00
Kevin Konrad
336de2d9fa add completion for qmk 2021-07-28 18:10:59 +02:00
YAKSH BARIYA
0b8b535187
Add completions for gping (#8181) 2021-07-28 17:53:44 +02:00
Branch Vincent
d8465e0a86 document --no-config 2021-07-27 23:00:23 +02:00
Fabian Homborg
8939a71ec6 An empty string means we're on the first line
Oops, this broke up-or-search!
2021-07-27 20:11:32 +02:00
Fabian Homborg
48e696bbb4 Update commandline state before completion
Fixes #8175.
2021-07-27 19:03:35 +02:00
Fabian Homborg
04b9a8b3b5 docs: Fix a label 2021-07-27 18:49:34 +02:00
Fabian Homborg
35ca42413d Simplify some parse_util functions
Don't just reflexively drop down to wchar_t.
2021-07-27 18:39:56 +02:00
Fabian Homborg
a6fa1c3b10 CHANGELOG 2021-07-27 18:39:37 +02:00
Fabian Homborg
29e9f4838a Run parse_util_detect_errors on -c commands
This didn't do all the syntax checks, so something like

    fish -c 'echo foo; and $status'

complained of a missing command `0` (i.e. $status), and

    fish -c 'echo foo | exec grep'

hit an assert!

So we do what read_ni does, parse each command into an ast, run
parse_util_detect_errors on it if it worked and then eval the ast.

It is possible to do this neater by modifying parser::eval, but I
can't find where.
2021-07-27 18:37:20 +02:00
Fabian Homborg
08209b3d9a Forbid $status as a command
This is slightly unclean. Even tho it would otherwise be syntactically
valid, using $status as a command is very very very likely to be an
error, like

    if not $status

We have reports of this surprisingly regularly, including #2773.

Because $status can only ever be a value from 0 to 255, it is also
very unlikely to be an actual command, and that command is very
unlikely to do what you want.

So we simply point the user towards the "conditions" help section,
that should explain things.
2021-07-27 18:37:20 +02:00
Fabian Homborg
b9ba3020f8 Don't check config directories with --no-config
If we don't use 'em, we should not complain about 'em.
2021-07-27 18:35:20 +02:00
Fabian Homborg
6e7d497a52 docs: Add a note explaining test 2021-07-27 18:35:20 +02:00
Fabian Homborg
d67470c482 docs: Link to the rest of the docs in fish_for_bash_users 2021-07-27 16:54:24 +02:00
Fabian Homborg
25af0230ad docs: Clarify stderr-nocaret being on by default 2021-07-27 16:54:03 +02:00
Fabian Homborg
d32e1c12be tinyexpr: Check for nan in ncr
Turns out this takes ages.

Fixes #8170
2021-07-26 18:40:50 +02:00
Fabian Homborg
4bb1c72a91 Revert "Clear to eol before outputting line in multi-line prompt"
This means, if we repaint with a shorter prompt, we won't overwrite the longer parts.

This reintroduces #8002, but that's a much rarer usecase - having a prompt that fills the entire screen,
in certain terminals.

This reverts commit d3ceba107e.

Fixes #8163.
2021-07-24 09:28:39 +02:00
Johannes Altmanninger
a2b30053dc Teach fish_indent about our feature flags
So it can handle syntax changes that call for different formatting.
2021-07-23 22:58:51 +02:00
Johannes Altmanninger
cc32b4f2a7 Make '&' only background if followed by a separating character
This is opt-in through a new feature flag "ampersand-nobg-in-token".

When this flag and "qmark-noglob" are enabled, this command no longer
needs quoting:

	curl https://example.com/thing?foo=bar&duran=duran

Compared to the previous approach e1570a4 ("Let '&' only separate as
the first char of a word"), this has some advantages:

1. "&&" and "&>" are no longer affected. They are still special, even
   if used between tokens without spaces, like "echo bar&>foo".
   Maybe this is not really *better*, but it avoids risking to annoy
   users by breaking the old variant.

2. "&" is still special if at the end of a token, like in "sleep 1&".

Word movement is not affected by the semantics change, so Alt-F and
friends still stop at every "&".
2021-07-23 22:58:51 +02:00
Johannes Altmanninger
6c0af841e2 completions/set: fix quoting error 2021-07-23 22:02:01 +02:00
Johannes Altmanninger
72fd328ad2 fish_clipboard_{copy,paste}: only use xsel/xclip if $DISPLAY is set
Ubuntu's fish package on WSL 1 has xsel as recommended dependency,
even though there is no X server available.  This change makes us
use Windows' native clipboard even when xsel is installed.
2021-07-23 20:55:07 +02:00
ridiculousfish
938879a85a Remove a stale comment and add a missing initializer 2021-07-23 11:22:45 -07:00
ridiculousfish
5f7e03ccf4 Introduce noncopyable_t and nonmovable_t
These are little helper types that allow us to get rid of lots of
'=delete' declarations.
2021-07-23 11:19:42 -07:00
ridiculousfish
e9ff3f2e65 Remove a stale comment. 2021-07-23 11:19:42 -07:00
Fabian Homborg
7167ba6e08 Work around Terminal.app's awkward alt-left/right sequences
Just do the more involved thing.

Blergh.

Fixes #2330.
2021-07-23 19:38:43 +02:00
Fabian Homborg
3cc59a9a12 docs: Document how complete groups options
Fixes #8146.
2021-07-23 19:29:16 +02:00
Fabian Homborg
7a5587de75 docs: Reword cd a bit 2021-07-23 18:00:57 +02:00
Fabian Homborg
152097ca34 doc: Some more rewordings
I'm struggling to avoid this massive list of files and directories.

Maybe a second section for integrators?
2021-07-23 18:00:57 +02:00
Aniruddh Agarwal
0445126c2e Undunder __fish_is_nth_token
We keep __fish_is_nth_token for compatibility and edit the
implementations of __fish_is_nth_token, __fish_is_first_token and
__fish_is_token_n to use fish_is_nth_token
2021-07-23 17:25:50 +02:00
Fabian Homborg
859edc9c2c Implicitly use $PWD in $CDPATH in completions and highlighting
We already do for the actual cd-ing itself.

Missed in #4484.

Fixes #8161.
2021-07-23 17:22:06 +02:00
Fabian Homborg
c35ffc58fc
Merge pull request #8134 from thunder-coding/complete-more-git-commands
Add missing completions for some git commands
2021-07-23 08:01:38 +02:00
Yaksh Bariya
e9a16ed7b5
Fix typos 2021-07-23 06:55:07 +05:30
Yaksh Bariya
692c6ae118 Add completions for git-sizer 2021-07-22 19:29:05 +02:00
Fabian Homborg
11da6db009 Cleanup of a comment 2021-07-22 19:19:49 +02:00
Yaksh Bariya
29fc74bc6a
Remove -F supplied to complete
Using `complete -F -c git -n __fish_git_needs_subcommand -a $command -d
$description` causes file completions to be forced on entire git command
which is not a desired result. Morever without the `-F` flag file
completions work just as expected and is useless addition
2021-07-22 17:06:59 +05:30
Yaksh Bariya
6f52c017ba
Resolve all conversations 2021-07-22 13:26:38 +05:30
Yaksh Bariya
54476d583b
Add flag completions for git mv 2021-07-22 13:25:12 +05:30