Commit Graph

171 Commits

Author SHA1 Message Date
ridiculousfish
2a680ebd12 Fix some miscellaneous warnings 2018-08-26 00:43:40 -07:00
Mahmoud Al-Qudsi
1b1bc28c0a Protect against loss of background jobs on exec
`exec` now exhibits the same behavior as `exit` and prompts the user to
confirm their intention to end the current process if there are
background jobs running. Running `exec` again immediately thereafter
will force the exec to go through.

Additionally, background jobs are reaped upon exec to prevent process
leaking (same as `exit`).
2018-08-20 22:52:47 -05:00
ridiculousfish
d40a82b4d3 Mark reader.cpp jump as static 2018-08-18 14:48:46 -07:00
Chris
1d68b52cbc Add till/repeat/reverse jump bindings
- Add support for:
  - Jumping to the character before a target.
  - Repeating the previous jump (same direction, same precision).
  - Repeating the previous jump in the reverse order.
- Enhance vi bindings.
2018-08-18 14:42:29 -07:00
Mahmoud Al-Qudsi
1c59a3f1a8 Fix traversal order of tokens in history completion
Fixes an issue introduced by e51e854. Closes #5150.
2018-08-16 14:07:38 -05:00
ridiculousfish
d87f00bdc9 Simplify history search
Remove features related to navigating forwards in history that are no
longer used.
2018-08-12 02:41:09 -07:00
ridiculousfish
e51e854d8d Clean up reader history search
Factor the history search fields into a new class.
As a side effect, this shares the deduplication logic, so that token search
no longer returns duplicates.

Fixes #4795
2018-08-12 02:40:15 -07:00
ridiculousfish
b0dc715d18 Factor update_autosuggestion to use can_autosuggest 2018-08-11 17:40:06 -07:00
ridiculousfish
4fdcc2e400 Begin to rationalize reader data stack
Switch from a manually maintained linked list to an explicit stack.
2018-08-11 13:17:00 -07:00
ridiculousfish
68c7ecd777 Remove reader_t::app_name field
It was unused
2018-08-11 13:02:50 -07:00
ridiculousfish
f7d846ad8b Make reader_push accept wcstring instead of wchar_t* 2018-08-11 12:43:11 -07:00
ridiculousfish
82bff2d692 Modernize some reader code for C++11 2018-08-11 12:39:24 -07:00
ridiculousfish
1f2b2b119a Remove some disabled (commented or ifdef'd out) code 2018-08-10 20:48:02 -07:00
Jon Eyolfson
c3ca108dbe Added const to methods which 'ought to be const' based on Const Checker 2018-08-09 19:05:47 -07:00
ridiculousfish
9c957eeef3 Prefer to not autosuggest existing arguments
This teaches autosuggestions to demote completions whose text matches an already
present argument.
2018-08-07 02:04:43 -07:00
Mahmoud Al-Qudsi
dcced5f1bc Replace \e with \x1B, as the former is a gcc extension
While supported by gcc and clang, \e is a gcc-specific extension and not
formally defined in the C or C++ standards.

See [0] for a list of valid escapes.

[0]: https://stackoverflow.com/a/10220539/17027
2018-06-18 00:01:47 -05:00
Swayam Raina
eb0539af60 Don't update CMD_DURATION if no command is requested
Fixes issue #4926
2018-05-27 11:37:36 -07:00
Fabian Homborg
feb6e9c90b Make DEFAULT_PROMPT and DEFAULT_TITLE work without functions
The prompt is a fallback that is overridden via a function file
anyway.

Do that with the title as well, so we can use just builtins.

This removes error messages when $fish_function_path is borked.
2018-05-12 13:53:45 +02:00
Mahmoud Al-Qudsi
515fc509ec Deprecate $_ in favor of (status current-command)
Closes #813.
2018-03-24 11:58:19 -05:00
Mahmoud Al-Qudsi
8a7104a0a4 Rename $_/$fish_title to $current_cmd 2018-03-10 21:33:16 -06:00
Mahmoud Al-Qudsi
9ca89fce6a Remove $_ and replace with $fish_title
Not sure about the new name. We've been using $version unprefixed and
now we also have $pid and $last_pid. $title is very generic.
2018-03-10 20:41:47 -06:00
Fabian Homborg
98d29b53de Refresh winsize before printing prompt
This allows prompts to react to $COLUMNS by e.g. omitting some parts.

We still fallback to a ">" prompt if that's still not short enough,
but now the user has a way of making a nicer prompt.

Fixes #904.
Fixes #4381.
2018-03-07 17:46:48 +01:00
ridiculousfish
c4d903ff98 Rationalize how the parser reports tokenizer errors
Remove the unnecessary SQUASH_ERROR flag and correctly report errors
generated from the tokenizer.
2018-02-23 17:28:12 -08:00
ridiculousfish
6673fe5457 Clean up tokenizer implementation
Rather than storing a bunch of "next_foo" fields, simply populate the
tok_t directly.
2018-02-23 14:31:13 -08:00
ridiculousfish
74e6a82849 Remove explicit 'void' parameters. 2018-02-18 19:12:45 -08:00
ridiculousfish
ea4e997dc9 Remove ends_with_pipe from reader
Now that parse_util_detect_errors() can report incomplete pipelines,
we no longer have to detect this in the reader.
2018-02-18 13:17:45 -08:00
slama
38418d6356 Enable multi-line edit when the line ends with a pipe (#1285) 2018-02-18 13:01:38 -08:00
ridiculousfish
01d87455e1 Teach parse_util_escape_string_with_quote about tildes
Properly escape literal tildes in tab completion results. Currently we
always escape tildes in unquoted arguments; in the future we may escape
only leading tildes.

Fixes #2274
2018-02-17 15:18:43 -08:00
ridiculousfish
0b2d8fd37e Switch some loops in handle_completions to C++11 range-based for looops 2018-02-17 13:10:05 -08:00
ridiculousfish
ba7b8a9584 Remove various empty or useless functions
In particular remove init()/destroy() functions that do nothing, or
destroy functions that only free memory.
2018-02-10 17:21:55 -08:00
ridiculousfish
a87970fbb5 Have the pager use a simple newline count to determine reserved lines
When the pager wants to use the full screen to show many options, it reserves
space at the top to see the command. Previously it pretended the command was a
prompt and engaged the prompt layout mechanism to compute these lines. Instead
let's juts count newlines since escape sequences within commands are very rare.
2018-02-04 14:14:37 -08:00
slama
27c1c06ed4 improve the size of completions page to show the entire prompt 2018-02-04 14:04:08 -08:00
ridiculousfish
9ba6b62791 Remove some ancient "#if 0' code and fix formatting errors 2018-02-04 14:03:08 -08:00
ridiculousfish
89709c3a89 Clean up some history search interfaces 2018-02-03 14:41:01 -08:00
ridiculousfish
5c2e6734c1 Normal text input to disable paging instead of search
Prior to this fix, if the user typed normal characters while the
completion pager was shown, it would begin searching. This feature was
not well liked, so we are going to instead just append the characters as
normal and disable paging. Control-S can be used to toggle the search
field.

Fixes #2249
2018-01-30 09:58:08 -08:00
ridiculousfish
d0d7bb75cd Add new pager-toggle-search input function
This adds a new input binding pager-toggle-search which toggles the
search field on and off when the pager is showing.
2018-01-30 09:58:08 -08:00
Fabian Homborg
dc95bfc1b1 [Pager] Make up without selected contents jump back into the pager
This makes it possible to select the last element of the completions
with just one keypress.

Fixes #3115.
2018-01-25 13:26:53 +01:00
ridiculousfish
094e853a20 Migrate tnode_t into new header tnode.h 2018-01-20 12:15:28 -08:00
ridiculousfish
f0f56a6910 Teach decoration_for_plain_statement about tnode, rename it get_decoration 2018-01-20 11:31:40 -08:00
ridiculousfish
cfe355554c Adopt tnode in reader_expand_abbreviation_in_command 2018-01-20 11:31:40 -08:00
Fabian Homborg
75ac482cec Don't crash when setting fish_history before reader is initialized
Not crashing is just soo much nicer.

Fixes #4619.
2018-01-01 13:02:39 +01:00
ridiculousfish
a99eecfad8 Wrap up source code and a parse tree into a new type parsed_source_ref_t
This will make it unnecessary to carry around the parse tree and source
separately, and enable some simplifications.
2017-12-22 14:40:15 -08:00
David Adam
848db48af5 Improve warning message when exiting with active jobs
Work on #4303.
2017-10-31 19:18:44 +08:00
David Adam
eb081481c6 warning message when exiting with active jobs uses PID of first process, not PGID
Work on #4303.
2017-10-31 19:17:21 +08:00
slama
7004c30f95 allow edit across newlines wherever the cursor is if the line ends with a backslash.
Fixes #4467
2017-10-18 11:58:01 -07:00
Aaron Gyes
18b06f3768 Rename CMD_DURATION to cmd_duration
Fixes #4414
2017-10-14 08:33:02 -07:00
Mahmoud Al-Qudsi
55b3c45f95 No longer put fish in own process group on startup
As discussed in #3805, this patch disables assigning fish to its own
process group at startup. This was trialled in #4349 alongside other
pgrp fixes which introduced additional problems, but this particular fix
seems to be OK.

Fixes #3805 and works around Microsoft/BashOnWindows#1653
2017-09-09 22:32:16 -05:00
ridiculousfish
3d40292c00 Switch env_var to using maybe_t
This eliminates the "missing" notion of env_var_t. Instead
env_get returns a maybe_t<env_var_t>, which forces callers to
handle the possibility that the variable is missing.
2017-09-01 00:14:42 -07:00
Kurtis Rader
55b2d36028 Remove unused vars identified by lint 2017-08-18 16:52:39 -07:00
Kurtis Rader
f872f25f5b change env_var_t to a vector of strings
Internally fish should store vars as a vector of elements. The current
flat string representation is a holdover from when the code was written
in C.

Fixes #4200
2017-08-18 16:24:30 -07:00