Commit Graph

168 Commits

Author SHA1 Message Date
ridiculousfish
fe68287cb0 Make miscellaneous variables thread-safe 2019-05-04 20:58:35 -07:00
ridiculousfish
1e57424011 Thread a parser into function_exists
Since this may autoload, it needs a parser with which to autoload.
2019-05-04 20:20:52 -07:00
ridiculousfish
bffacd2fbf Thread a parser into expansion
Expansion may perform command substitution, which needs to know the parser
to use.
2019-05-04 19:30:00 -07:00
ridiculousfish
4ce485525e Correct duplicate completion detection
Stop assuming that completions with the same hash are equal.
2019-05-04 18:35:22 -07:00
ridiculousfish
923a7ca0f0 Thread the parser into complete()
Eliminates uses of principal_parser
2019-05-04 18:17:18 -07:00
ridiculousfish
63bdc949ab Make completion request flags an enum_set 2019-05-04 17:55:57 -07:00
ridiculousfish
4ff50eba41 Remove autoload_t, rename autoloader_t to autoload_t
Now that there are no more clients of autoload_t, delete it and
rename autoloader_t to autoload_t. Also clean up the headers.
2019-04-27 15:47:08 -07:00
ridiculousfish
68a28106b2 Reimplement completion autoloading via autoloader_t
This switches the completion autoloading machinery to autoloader_t.
2019-04-27 15:37:24 -07:00
ridiculousfish
6ec7c50ace Stop removing functions and completions in autoload
autoloading has a "feature" where functions are removed in an LRU-fashion.
But there's hardly any benefit in removing autoloaded functions. Just stop
doing it.
2019-04-27 14:49:05 -07:00
David Gowers
38cadc9d4f Variables as commands are in fact supported, eval docs should not claim otherwise. (#5819)
Provide an example that somewhat justifies eval's existence in light of this change.

Also correct similar misinformation found in a comment.
2019-04-26 15:30:13 +02:00
ridiculousfish
96bc8a14ca Promote completion_mode_t to a real type
Eliminate big #defines like NO_COMMON.
2019-04-25 14:21:06 -07:00
ridiculousfish
496529b20a Remove EXPAND prefix from expand_flags and lowercase them 2019-04-25 11:34:49 -07:00
ridiculousfish
d8ab6290e8 Switch expand_flags_t to enum_set 2019-04-25 11:23:03 -07:00
ridiculousfish
dcaac58f45 Rename expand_error_t to expand_result_t and make it class enum
Also lowercase it all.
2019-04-25 10:47:28 -07:00
ridiculousfish
2e119813e1 get_abbreviations to accept an environment_t
Now that we don't have dorky snapshotting, thread an dnvironment_t through
get_abbreviations. Removes a usage of env_stack_t::principal().
2019-04-16 22:27:01 -07:00
Mahmoud Al-Qudsi
e0e0fe9dd3 Re-implement eval as a regular builtin
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
2019-04-12 07:04:15 -05:00
Mahmoud Al-Qudsi
2fe2169065 Make eval a decorator
`eval` has always been implemented as a function, which was always a bit
of a hack that caused some issues such as triggering the creation of a
new scope. This turns `eval` into a decorator.

The scoping issues with eval prevented it from being usable to actually
implement other shell components in fish script, such as the problems
described in #4442, which should now no longer be the case.

Closes #4443.
2019-04-11 10:36:49 -05:00
Mahmoud Al-Qudsi
0bda853dc7 Add detection of eval to the parser
While `eval` is still a function, this paves the way for changing that
in the future, and lets the proc/exec functions detect when an eval is
used to allow/disallow certain behaviors and optimizations.
2019-04-10 21:19:57 -05:00
Aaron Gyes
b4ddd797e3 remove unused wcstring 2019-04-04 14:24:36 -07:00
Aaron Gyes
d837eee09d remove some wcstring -> wchar_t* -> wcstring conversions
Mostly related to usage _(L"foo"), keeping in mind the _
macro does a wcstring().c_str() already.

And a smattering of other trivial micro-optimizations certain
to not help tangibly.
2019-03-14 15:21:08 -07:00
Aaron Gyes
d5ac239f68 This commit changes wchar.h includes to cwchar, and uses std::
for everything it provides.
2019-03-12 15:09:36 -07:00
ridiculousfish
dc27de8190 Rename reader_interrupted to reader_test_and_clear_interrupted 2019-03-02 15:17:00 -08:00
Fabian Homborg
ddfad001eb Remove unnecessary string copy
This called function_exists_no_autoload with a c_str().

Only that takes a wcstring, so the constructor gets called which
copies that.
2019-02-04 17:10:53 +01:00
ridiculousfish
d3fa58d621 Cleanup common.h
Remove a bunch of headers, simplify lots of code, migrate it into .cpp files.

Debug build time improves by ~3 seconds on my Mac.
2019-02-03 18:22:38 -08:00
Dan Zimmerman
857561ca14 Fix warnings when compiling on macos
These warnings were appearing and annoying me so Im making a PR to fix
them.
2019-01-17 13:56:17 -06:00
Fabian Homborg
58b696bed1 complete: Don't allow wrapping a command with itself
Double-fixes #5541, by not allowing it to happen.
2019-01-17 09:49:50 +01:00
ridiculousfish
3b1709180f Instantize env_get 2019-01-10 20:07:53 -08:00
ridiculousfish
6f52e6bb1c Instantize contents of exec.cpp and others 2019-01-10 20:07:47 -08:00
ridiculousfish
abcd24f716 Eliminate env_snapshot_t::current()
These uses are better served by passing in the real environment stack,
now that we have environment_t as a shared base class.
2019-01-10 20:07:14 -08:00
ridiculousfish
421fbdd52a Instantize env_get_pwd_slash
This requires threading environment_t through many places, such as completions
and history. We introduce null_environment_t for when the environment isn't
important.
2019-01-10 20:01:28 -08:00
ridiculousfish
94adb53b1f Eliminate complete_set_variable_names 2019-01-10 20:29:10 -08:00
ridiculousfish
e6b13c6bac Begin to thread environments explicitly through completions 2019-01-10 20:29:10 -08:00
Mahmoud Al-Qudsi
bfe08a471d Remove fish_mutex_t wrapper around std::mutex
@ridiculousfish had introduced this in 3a45cad12e
to work around an issue with Coverity Scan where it couldn't tell the
mutex was correctly locked, but even with the `fish_mutex_t` hack, it
still emits the same warnings, so there's no pointing in keeping it.
2018-12-30 20:37:36 -06:00
Fabian Homborg
7533fa89d4 complete: Stringify 2018-10-23 19:10:14 +02:00
ridiculousfish
202bf0bede Tab complete abbreviations
This allows abbreviations to be expanded by tab completions.

Fixes #3233
2018-10-16 16:15:27 -07:00
ridiculousfish
161196fe53 Simplify wildcard_complete prototype
Rather than accepting both a 'description' and a 'description function',
accept just the description function.
2018-10-16 15:43:42 -07:00
ridiculousfish
90d89a3262 Use more move constructors in expansion
Reduce allocations by switching to move semantics.
clang-tidy detects some use-after-moves.
2018-10-11 02:03:28 -07:00
ridiculousfish
767b7a2180 Migrate the completion set to owning_lock_t 2018-10-05 09:05:59 -07:00
ridiculousfish
1bc4cf2318 More const and atomic correctness 2018-10-01 09:59:22 -07:00
ridiculousfish
20cb62440c Eliminate some mutable global variables
Make them const or otherwise get rid of them
2018-09-29 00:20:50 -04:00
Mahmoud Al-Qudsi
a0110d296c Refactor function_get_[desc/definition] to pass-by-reference 2018-09-26 21:03:55 -05:00
ridiculousfish
1473f952d4 Make contains() more general
Allow contains() to find arbitrary values in arbitrary vectors, and adopt it
in place of std::find.
2018-08-11 22:23:20 -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
ridiculousfish
459c01df76 Slightly refactor completion calculation
Move more stuff into completer_t
2018-08-07 00:40:01 -07:00
ridiculousfish
3175ccf266 Use move semantics when returning completions
Avoids some string copies
2018-08-06 23:58:48 -07:00
ridiculousfish
c636a455a0 Add locking to try_complete_user
This uses the thread-unsafe getpwent(). Add a lock around the whole section
to avoid the crash identified in #5088
2018-07-15 15:50:56 -07:00
Fabian Homborg
8de5af5f9e Fix off-by-one in complete_cmd_desc
The substring constructor (string(str, pos)) includes pos, so we need
to add one. Also be careful not to go over the length again.
2018-06-03 19:17:02 +02:00
Fabian Homborg
72e9d41dcc [complete] Fix crash with __fish_describe_command
Our completion machinery calls our `__fish_describe_command` function
to describe commands via apropos. Only it trusts the output a bit too
much, so it crashes when any line from that is shorter than the
original string.

Fix this by skipping any string that is shorter than the original,
since it can't be a match anyway.

Also stop doing wcslen so often - std::strings are nice!

Fixes #5014.
2018-06-01 20:16:23 +02:00
ridiculousfish
ba69f8f71d Remove an unused variable 2018-05-27 15:46:30 -07:00
Mahmoud Al-Qudsi
3cda5ac59b Clean up complete.cpp code
Embrace C++11 ranged for loops.
2018-05-12 11:23:43 -05:00