Johannes Altmanninger
14c6a12782
Use accessor functions for editable_line_t::{text,position}
...
This is paving the way for undo, where we want to have one central place
for modifying an editable_line_t.
2020-02-06 01:30:45 +01:00
ridiculousfish
1101cff566
Factor out some of the crazy logic in reader_interactive_init
2020-01-31 11:11:03 -08:00
ridiculousfish
28a8d0dbf7
Continued adoption of autoclose_fd_t and exec_close
2020-01-29 14:16:16 -08:00
ridiculousfish
376529a46d
Clean up reader_read
...
Stop having reader_read close the input file descriptor. Make other
modernizations.
2020-01-28 11:39:26 -08:00
ridiculousfish
fc4557c784
Eliminate wopen()
...
It was large and mostly unnecessary. Prefer wopen() followed by
fdopen().
2020-01-28 10:43:37 -08:00
Fabian Homborg
3bb15defbb
Replace debug() with flog
...
PR #6511
Flog has the advantage of having *categories*, not severities, so it'll be easier to get output for a certain subsystem now.
2020-01-26 14:13:17 +01:00
ridiculousfish
38f4330683
Rationalize $status and errors
...
Prior to this fix, fish was rather inconsistent in when $status gets set
in response to an error. For example, a failed expansion like "$foo["
would not modify $status.
This makes the following inter-related changes:
1. String expansion now directly returns the value to set for $status on
error. The value is always used.
2. parser_t::eval() now directly returns the proc_status_t, which cleans
up a lot of call sites.
3. We expose a new function exec_subshell_for_expand() which ignores
$status but returns errors specifically related to subshell expansion.
4. We reify the notion of "expansion breaking" errors. These include
command-not-found, expand syntax errors, and others.
The upshot is we are more consistent about always setting $status on
errors.
2020-01-25 17:28:41 -08:00
Fabian Homborg
8b1ac0912b
Add reader flog category
...
For both input and reader, because the "reader" term is more general
and we don't have enough messages to justify multiple categories
2020-01-19 14:55:08 +01:00
Fabian Homborg
024e03ab1e
Replace debug(1) with FLOGF(warning)
2020-01-19 14:22:39 +01:00
Fabian Homborg
384f18a51c
Remove last remaining debug(0)
...
Replace with FLOGF.
2020-01-19 13:31:25 +01:00
ridiculousfish
1978ac87a1
Remove reader_test_should_cancel
...
Use cancel_checker more pervasively.
2020-01-16 15:21:45 -08:00
ridiculousfish
0f7bba5f0e
Introduce operation_context_t
...
This commit recognizes an existing pattern: many operations need some
combination of a set of variables, a way to detect cancellation, and
sometimes a parser. For example, tab completion needs a parser to execute
custom completions, the variable set, should cancel on SIGINT. Background
autosuggestions don't need a parser, but they do need the variables and
should cancel if the user types something new. Etc.
This introduces a new triple operation_context_t that wraps these concepts
up. This simplifies many method signatures and argument passing.
2020-01-16 15:21:28 -08:00
ridiculousfish
db98ee13a9
Make complete() return the completion list directly
...
Returning it through a pointer was a remnant of pre C++-11 days.
2020-01-16 15:18:50 -08:00
ridiculousfish
4bb18eaf42
Use completion_list_t naming everywhere
...
std::vector<completion_t> -> completion_list_t
2020-01-16 15:18:49 -08:00
ridiculousfish
98e714f98f
clang-format .cpp and .h files
2020-01-16 15:18:28 -08:00
ridiculousfish
7e1270ae70
Be more disciplined about cancellation signals
...
Rather than storing a "should cancel" flag in the parser, store the
actual signal which triggered cancellation.
2020-01-14 15:20:04 -08:00
Fabian Homborg
31e6ae0099
Ignore EPERM for setpgid
...
In case we are a session leader, we get a harmless EPERM, yet we used
to quit. Stop doing that.
Fixes #6499 .
2020-01-13 18:57:19 +01:00
Rosen Penev
b1349f44f6
[clang-tidy] Add const to reference
...
Found with performance-unnecessary-copy-initialization
2019-12-26 21:37:15 -08:00
Rosen Penev
2ecc386121
[clang-tidy] Remove redundant c_str
...
Found with readability-redundant-string-cstr
2019-12-26 21:25:07 -08:00
Fabian Homborg
e986970f4d
Remove vi_arg_digit and vi_delete_to
...
They don't do anything anymore.
2019-12-25 10:44:27 +01:00
Mathieu Duponchelle
15c1b3ed4b
Place fish in its own process group when launched with -i
...
Fixes #5909
2019-12-23 10:32:37 +01:00
ridiculousfish
c19407ab0f
Default parser_t::eval()'s block type to top
...
This is the parameter value at every call site except one. Just make it the
default.
2019-12-22 16:27:03 -08:00
ridiculousfish
a59f35a378
Make block_type_t an enum class
2019-12-22 15:37:14 -08:00
ridiculousfish
4529e7d183
Reverse the order of the block stack
...
Previously, the block stack was a true stack. However in most cases, you
want to traverse the stack from the topmost frame down. This is awkward
to do with range-based for loops.
Switch it to pushing new blocks to the front of the block list.
This simplifies some traversals.
2019-12-22 15:07:41 -08:00
Rosen Penev
7d1cc992e5
[clang-tidy] Simplify boolean expressions
...
Found with readability-simplify-boolean-expr
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-29 23:46:51 -08:00
Rosen Penev
4087b2ee15
[clang-tidy] Use bool literals
...
Found with modernize-use-bool-literals
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-29 23:46:50 -08:00
Rosen Penev
69d0bb7c0d
io.h: Add missing override
...
Found with clang's -Winconsistent-missing-destructor-override
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-25 14:50:40 -08:00
Rosen Penev
586ac3dfa7
[clang-tidy] Convert loops to range based
...
Found with modernize-loop-convert
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-25 14:50:40 -08:00
Rosen Penev
1055ff321c
[clang-tidy] Replace NULL with nullptr
...
Found with modernize-use-nullptr
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-25 14:23:03 -08:00
Rosen Penev
0dfa7421f3
[clang-tidy] Convert C casts to C++ ones
...
Found with google-readability-casting
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-25 14:17:49 -08:00
Rosen Penev
7f62e30731
[clang-tidy] Replace size comparisons with empty
...
Found with readability-container-size-empty
Signed-off-by: Rosen Penev <rosenp@gmail.com >
2019-11-25 14:13:33 -08:00
Jason
3cf6ebc0e1
Amend typos and grammar errors
2019-11-25 13:07:15 +01:00
Ray Hogenson
98a98b1424
Change vi selection mode to be inclusive
...
The current cursor position should be included in the selection to be
consistent with the behavior of vi.
Fixes #5770
2019-11-19 20:25:10 +01:00
ridiculousfish
52e900690b
Make history_search_type_t an enum class
2019-11-02 18:56:16 -07:00
ridiculousfish
a7f1d2c0c7
Add support for fish_trace variable to trace execution
...
This adds support for `fish_trace`, a new variable intended to serve the
same purpose as `set -x` as in bash. Setting this variable to anything
non-empty causes execution to be traced. In the future we may give more
specific meaning to the value of the variable.
The user's prompt is not traced unless you run it explicitly. Events are
also not traced because it is noisy; however autoloading is.
Fixes #3427
2019-11-02 14:40:57 -07:00
Johannes Altmanninger
6702c84d15
Prevent buffer overflow when custom completions edit the commandline
...
This was introduced in a7ea7648c3
"Completion: maintain cursor position when there is no completion"
2019-11-01 13:21:49 +01:00
Aaron Gyes
d1970c7f2e
read_ni: be more specific in error if a file can't be read
...
for example, `fish /etc` now tells us "Is a directory"
make a couple char constants wchar_t constants
2019-10-14 01:43:35 -07:00
Aaron Gyes
5d84d3fe48
reader.cpp: remove unused pointer in read_ni
...
literally prehistoric in git blame
2019-10-14 00:42:03 -07:00
ridiculousfish
1a65e18ba8
Clean up some tokenization
...
Remove TOK_NONE
Turn token_type into an enum class
Make next() turn a maybe_t<tok_t> instead of a bool
2019-10-13 16:06:16 -07:00
ridiculousfish
82eca4bc86
Run clang-format on all files
...
The main change here is to reorder headers.
2019-10-13 15:50:48 -07:00
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
domdom
76f4b65981
Add prefix history search
2019-10-05 11:27:32 -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
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
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
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
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