Per Bothner
afb8f42f39
Emit omitted-newline string before fish_prompt event
...
See issue #6118 "omitted-newline string emitted after fish_prompt event"
2019-10-06 10:52:12 -07:00
Per Bothner
dfc45f3e10
Clear line if new indentation greater than old.
...
Make sure initial indentation is skipped, rather than written as spaces.
This is a tweak to pull request #5928 .
2019-10-06 10:34:55 -07:00
Johannes Altmanninger
7017a2fcf9
Unexpand abbreviations' variable names before completing them
...
Fixes #6166
2019-10-06 14:42:42 +02:00
domdom
76f4b65981
Add prefix history search
2019-10-05 11:27:32 -07:00
Johannes Altmanninger
e167714899
Raise the recursion limit of complete
...
Users should generally prefer to use complete --wraps but this
corrects some unexpected behavior.
Fixes #3474
2019-10-03 21:25:19 +02:00
Johannes Altmanninger
aa011f70a8
Print an error when complete reaches its recursion limit
2019-10-03 21:25:19 +02:00
Aaron Gyes
19c575e116
builtin functions: colorize output if interactive
...
We can also get rid of the | fish_indent --ansi stuff in type.fish
2019-09-25 04:18:06 -07:00
Aaron Gyes
8230755bfd
Make sure rgb_color_t doesn't grow
...
For years the comment above the class claimed it was 4 bytes, but
it had grown to 5. Add a static_assert() to prevent that from
happening again.
2019-09-24 23:34:10 -07:00
Aaron Gyes
e6c72f74a8
make rgb_color_t smaller
...
rgb_color_t was 5 bytes, now it's 4 again.
big arrays holding colors are going to be smaller.
2019-09-22 21:16:30 -07:00
ridiculousfish
91c4dad812
Revert "use std::tolower"
...
This reverts commit a3db4128bc
.
This broke the build.
2019-09-22 15:33:08 -07:00
Aaron Gyes
a3db4128bc
use std::tolower
2019-09-22 15:47:22 -07:00
ridiculousfish
a19d9b2e73
Add a test for #6130
2019-09-22 14:06:38 -07:00
Johannes Altmanninger
bc533ad939
Fix completion inside command substitution inserting spurious quote
...
Reproducer: type `: (: ""`, move the cursor after the second colon and press tab.
2019-09-22 14:06:38 -07:00
ridiculousfish
70a1d8314c
Optimize parse_color
2019-09-21 19:36:56 -07:00
ridiculousfish
18b56637f7
self-insert bindings to insert their own sequence
...
Prior to this fix, self-insert would always wait for a new character.
Track in char_event what sequence generated the readline event, and then
if the sequence is not empty, insert that sequence.
This will support implementing the space binding via pure readline
functions.
2019-09-21 15:58:57 -07:00
ridiculousfish
1ecbe363d0
Correct an assertion message
2019-09-21 15:17:09 -07:00
ridiculousfish
3f7bc7232e
yank_POP -> yank_pop
2019-09-21 14:31:22 -07:00
ridiculousfish
5f64972908
Do not try the same (command, wraps) pair more than once when completing
...
This prevents runaway wrap chains. Fixes #5638 .
2019-09-21 14:09:38 -07:00
ridiculousfish
77dbe109e0
Allow cancellation out of expanding a runaway wrap chain
...
This makes it easier to control-C out of a completion.
2019-09-21 13:11:45 -07:00
ridiculousfish
3f2f44ce73
Introduce reader_test_should_cancel
...
This centralizes the logic around cancellation due to either sigint or a
stale threaded operation.
2019-09-21 13:07:55 -07:00
ridiculousfish
95aea7839d
Show wrap targets when printing a function
...
Fixes #1625
2019-09-21 12:48:51 -07:00
ridiculousfish
a1f1abc137
Stop passing true to escape_string
...
It wants a flags, not a boolean.
2019-09-21 12:40:24 -07:00
Johannes Altmanninger
a7ea7648c3
Completion: maintain cursor position when there is no completion
...
Previously, tab-completion would move the cursor to the end of the current token, even
if no completion is inserted. This commit defers moving the cursor until we insert a completion.
Fixes #4124
2019-09-21 12:50:52 -07:00
Johannes Altmanninger
e9e92178a9
completions: simplify prefix computation
2019-09-21 12:50:52 -07:00
Johannes Altmanninger
6c5c0a73eb
remove useless call, fix comment
2019-09-21 12:50:52 -07:00
Aaron Gyes
2b7b70a64f
Ellipsis OCD
2019-09-19 11:48:37 -07:00
Aaron Gyes
fda8ad429b
parse_util.cpp: remove truncate_string()
...
We already have something that does this
2019-09-19 10:32:07 -07:00
Aaron Gyes
cb79d8fa97
Colorize complete
output
...
If interactive, `complete` commands are highlighted like they would
be if typed. Adds a little fun contrast and it's easier to read.
Moved a function out of fish_indent to highlight.h
2019-09-19 04:27:33 -07:00
Aaron Gyes
620761b9b9
complete: print long option names for less common ones
...
we now print --long options for ones I arbitrarily decided
are less likely to be remembered.
Also fixed the `--wraps` items at the end not being escaped
2019-09-19 04:21:24 -07:00
Aaron Gyes
e9ee2fb089
complete: support -k (--keep-files) in printed completions
2019-09-19 02:01:33 -07:00
Aaron Gyes
7302dcc12b
complete: terser output with short options
...
Most of our completion scripts are written using the short options
anyhow, and this makes it less likely the output will span several
lines per command
2019-09-19 01:50:26 -07:00
David Adam
3ae12ac4d3
Revert "Escape separators (colon and equals) to improve completion"
...
This reverts commit f7dac82ed6
from pull
request #6059 .
As discussed in #6099 , this caused a regression in some completions (eg
dd).
2019-09-19 14:38:16 +08:00
Aaron Gyes
f35e18bb9b
complete.cpp: don't double escape commands in complete
output
...
The argument to --command was escaped both here and in
append_switch(), potentially producing incorrect output
2019-09-18 16:21:21 -07:00
Johannes Altmanninger
8baea8b157
Do not add a space after completion if one is already there
...
Example: type `cd --help --help`, move the cursor inside the first `--help` and press tab.
This used to add redundant spaces.
2019-09-18 14:02:24 -05:00
Aaron Gyes
22811ebcf6
Remove unused macros
...
Most just left behind after actual code was moved into different files.
2019-09-18 01:31:03 -07:00
Aaron Gyes
715836cb0a
builtin_set_color.cpp: remove unnecessary .c_str()
2019-09-18 00:09:23 -07:00
Aaron Gyes
5f05d9734c
builtin_set_color.cpp: colorize set_color --print-colors
...
Each named color is now printed in that color, only if
hooked up to a TTY. Shouldn't affect scripts.
2019-09-18 00:05:09 -07:00
Aaron Gyes
61f0756fe6
builtins: Use standard builtin.h error macros more
2019-09-17 22:04:33 -07:00
ridiculousfish
533ee65963
Allow binding nul (zero byte)
...
This sequence can be generatd by control-spacebar. Allow it to be bound
properly.
To do this we must be sure that we never round-trip the key sequence
through a C string.
2019-09-14 16:37:57 -07:00
ridiculousfish
5afcc439a5
Clean up input_terminfo_get_sequence
2019-09-14 14:59:01 -07:00
ridiculousfish
5ebcd3de98
Remove some unnecessary string formatting
2019-09-14 14:22:37 -07:00
ridiculousfish
06269ed67d
Remove NOT_A_WCHAR
...
It's now unused.
2019-09-14 13:18:04 -07:00
ridiculousfish
8747018cbc
Use maybe_t in unescape_string_internal
2019-09-14 13:17:22 -07:00
ridiculousfish
fa1dab040b
Use maybe_t in read_unquoted_escape
2019-09-14 12:54:38 -07:00
ridiculousfish
cc5e29734b
Use maybe_t in string_last_char
2019-09-14 11:56:02 -07:00
Johannes Altmanninger
0ecfc25961
Fix highlighting of redirection to -
(close file descriptor)
...
Fixes #6092
2019-09-14 13:04:27 -05:00
David Adam
77ef2ef6c3
jobs: return success when a job is found via --last
...
Closes #6104 .
2019-09-14 13:01:36 -05:00
ridiculousfish
56d2942f59
Minor cleanup of how jobs store their command string
2019-09-09 09:07:25 -07:00
ridiculousfish
535a448d0e
Remove an errant fprintf
2019-09-08 15:44:07 -07:00
ridiculousfish
b2fe2f9ff3
Correct escaping and add tests for bracket completion
...
Add some tests for new bracket completion behavior, and fix an escaping
bug where \\[ was incorrectly marked as escaping.
2019-09-08 15:43:20 -07:00
Johannes Altmanninger
bc3dde997d
escape square brackets in an argument before completing it
...
fixes #5831
2019-09-08 12:27:58 -07:00
ridiculousfish
e79df33e3a
Disallow parsing 'and' and 'or' as commands
...
Except for and --help and or --help
Fixes #6089
2019-09-08 11:09:32 -07:00
ridiculousfish
fa6bac1283
Correctly implement and --help and or --help
2019-09-08 10:42:24 -07:00
Johannes Altmanninger
962bfa9668
Escape literal dollar signs in quoted completions
...
Closes #6060 .
2019-09-07 13:52:40 -05:00
Mahmoud Al-Qudsi
f854e3dc29
Try fixing __has_attribute errors on Travis macOS
2019-09-05 23:11:59 -05:00
Mahmoud Al-Qudsi
80610addf8
Avoid warnings about unsupported clang::weak_import w/ GCC on macOS
2019-09-05 23:00:46 -05:00
ridiculousfish
b760fd9064
Correctly set g_use_posix_spawn at launch again
2019-09-05 11:00:52 -07:00
Johannes Altmanninger
f7dac82ed6
Escape separators (colon and equals) to improve completion
...
Fish completes parts of words split by the separators, so things like
`dd if=/dev/sd<TAB>` work.
This commit improves interactive completion if completion strings legitimately
contain '=' or ':'. Consider this example where completion will suggest
a🅰️ 1 and other files in the cwd in addition to a:1
touch a:1; complete -C'ls a:'
This behavior remains unchanged, but this commit allows to quote or escape
separators, so that e.g. `ls "a:<TAB>` and `ls a\:<TAB>` successfully complete
the filename.
This also makes the completion insert those escapes automatically unless
already quoted.
So `ls a<TAB>` will give `ls a\:1`.
Both changes match bash's behavior.
2019-09-02 14:27:21 -07:00
ridiculousfish
9fd9f70346
Restore terminal modes after sending SIGCONT
...
Fixes #2214
Thanks to @bruce-hill for the patch.
2019-09-01 17:24:23 -07:00
Johannes Altmanninger
068aba1902
remove redundant call (done in constructor of completion_t)
2019-08-31 12:05:49 -07:00
Mahmoud Al-Qudsi
af4b54e635
Change WSL version check to a hard error, but include a bypass
...
Instead of warning (debug level 1), we now emit an error (debug level 0) if a known bad version of
WSL is detected. However, `FISH_NO_WSL_CHECK` can now be defined to skip both the check and the
startup message.
2019-08-25 18:50:17 -05:00
Mahmoud Al-Qudsi
44022e65c2
Revert "Remove the WSL warning"
...
This reverts commit 5101bdeb9f
.
2019-08-25 18:29:46 -05:00
ridiculousfish
99c498d3d7
Use move semantics in trim and history_item_t
2019-08-25 13:37:06 -07:00
David Adam
225b1204d6
read: add --list as synonym for --array
...
Work on #5846 .
2019-08-22 21:24:17 +08:00
ridiculousfish
903e7c6d5e
history_lru_cache_t to use move semantics
2019-08-18 12:14:07 -07:00
ridiculousfish
9b2b7f787e
Migrate history profiling to flog
2019-08-18 11:14:45 -07:00
ridiculousfish
0da87d3e5f
Equip history_item_t with a default constructor
2019-08-17 20:01:44 -07:00
ridiculousfish
5101bdeb9f
Remove the WSL warning
...
This warning is annoying and there is no way to disable it.
Ping #5661 . Ping #5298 . Closes #6038
2019-08-16 20:59:53 -07:00
ridiculousfish
f137f24d75
Initialize a const variable
...
Fixes #6041
2019-08-16 17:50:41 -07:00
ridiculousfish
a87e0183df
Stop rewriting the history file on every command
...
fish is designed to append to the history file in most cases. However
save_internal_via_appending was never returning success, so we were
always doing the slow rewrite path. Correctly return success.
Fixes #6042
2019-08-15 13:49:17 -07:00
ridiculousfish
7ab291775a
Add flog logging to history
2019-08-15 13:42:23 -07:00
Aaron Gyes
edc8d5d7a3
string-replace-fewer-backslashes -> regex-easyesc
...
This shortens a very long feature name.
See discussion in #5805
2019-08-13 22:32:04 -07:00
ridiculousfish
ce178fd6fd
Make escape_yaml_fish_2_0 and unescape_yaml_fish_2_0 static
...
They no longer need to be exposed.
2019-08-12 09:22:21 -07:00
ridiculousfish
3ae5b23971
Migrate append_history_item_to_buffer to history_file.cpp
...
Also eliminate history_output_buffer_t, which no longer does anything useful.
2019-08-12 09:17:10 -07:00
ridiculousfish
6eebe4cc83
Eliminate history_lru_item_t
...
history_item_t is enough
2019-08-11 14:26:22 -07:00
ridiculousfish
6b008c3eae
Stop caching the lowercase string contents in history items
2019-08-11 13:41:04 -07:00
ridiculousfish
92e9a34b47
Simplify history_output_buffer_t
2019-08-11 13:08:31 -07:00
ridiculousfish
2ddde381d4
Clean up next_line() interface and implementation
2019-08-11 12:57:09 -07:00
ridiculousfish
91987a4548
Migrate history file format stuff into new file history_file.cpp
...
Breaks up the history.cpp monolith.
2019-08-11 12:45:04 -07:00
ridiculousfish
74357bac91
Remove an errant semicolon
2019-08-10 16:47:45 -07:00
ridiculousfish
fd5d8c1949
Remove __packed
...
We can use the new C++11 enum type feature to stop using this non-portable
__packed.
2019-08-10 16:04:05 -07:00
ridiculousfish
30fd526fc1
Correct an out-of-bounds index in screen
...
Fixes #6037
2019-08-10 14:32:55 -07:00
ridiculousfish
0dc5eaeb97
reader_expand_abbreviation_in_command to return maybe_t<wcstring>
2019-08-06 16:09:23 -07:00
Fabian Homborg
2c32885a2d
Fix build on old gcc by using old-school initialization
...
It appears Gcc 4.8 doesn't get this particular expression, so we just
revert to the old `type foo = bar` style from the new `type foo{bar}`.
Fixes #6027 .
2019-08-05 18:08:13 +02:00
ridiculousfish
29dede8139
Migrate parse_util_detect_errors to a free function
2019-08-04 14:49:56 -07:00
ridiculousfish
73bf60754c
Don't assign jobs to fish's pgrp if there's no external process
...
Fixes #6011
2019-08-03 14:43:55 -07:00
ridiculousfish
95c97619c6
Use cbegin() in one place in reader
2019-07-31 14:23:41 -07:00
Fabian Homborg
6500765256
Allow switch
with something that expands to nothing
...
Meaning empty variables, command substitutions that don't print
anything.
A switch without an argument
```fish
switch
case ...
end
```
is still a syntax error, and more than one argument is still a runtime
error.
The none-argument matches either an empty-string `case ''` or a
catch-all `case '*'`.
Fixes #5677 .
Fixes #4943 .
2019-07-31 14:08:28 +02:00
ridiculousfish
5b90fa0bda
Add a missing reference to a range-based for loop
2019-07-29 21:39:05 -07:00
ridiculousfish
a33f0eb636
Clean up some logic around when process exit events are sent
2019-07-28 14:36:57 -07:00
ridiculousfish
a40a4c0c54
Add some new tricks to fish_test_helper
...
Allow fish_test_helper to report if it is in the foreground, and to SIGINT
its parent.
2019-07-27 11:00:07 -07:00
ridiculousfish
822b53c67a
Don't color a whole string invalid because of an unclosed quote
...
When syntax highlighting a quoted string, if the string is not closed,
only show the opening quote as an error, not the whole string.
2019-07-24 12:43:47 -07:00
ridiculousfish
c0053ceef5
highlighter_t to return color array directly
...
Saves some copying and allocations.
2019-07-24 12:42:18 -07:00
ridiculousfish
554ee240b3
Correct handling of explicitly separated output when all elements are empty
...
Previously when propagating explicitly separated output, we would early-out
if the buffer was empty, where empty meant contains no characters. However
it may contain one or more empty strings, in which case we should propagate
those strings.
Remove this footgun "empty" function and handle this properly.
Fixes #5987
2019-07-21 14:00:27 -07:00
ridiculousfish
e8c6de8055
Correctly export empty universal variables
...
Fixes #5992
2019-07-21 12:45:29 -07:00
ridiculousfish
1f854ec284
Accept a pwd in resolve_file_redirections_to_fds
...
Conceptually allow multiple of these to run in parallel
2019-07-20 17:25:25 -07:00
ridiculousfish
8ec568d21f
Add some tests to path_apply_working_directory
2019-07-15 17:56:06 -07:00
ridiculousfish
8181883111
Minor refactoring of logic around when a job wants to claim the terminal
...
Introduce should_claim_terminal() which encapsulates an && exprsesion which
was previously repeated a lot.
2019-07-12 13:31:56 -07:00
ridiculousfish
d577eb4aaa
Only use the global fish_complete_path and fish_function_path
...
Prior to this fix, fish would attempt to react if a local fish_complete_path
or fish_function_path were set. However this has never been very well tested
and will become impossible with concurrent execution. Always use the global
values.
2019-07-12 12:40:12 -07:00
ridiculousfish
0e4fe53718
clang-format some files
2019-07-06 13:11:50 -07:00