Commit Graph

168 Commits

Author SHA1 Message Date
Rosen Penev
33351d7657 [clang-tidy] remove static from namespace
Found with readability-static-definition-in-anonymous-namespace

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-02-22 09:34:02 +01:00
ridiculousfish
d957f6b302 Centralize some calls to principal_parser()
Eventually perhaps we can get rid of the notion altogether.
2020-02-08 12:33:47 -08:00
Fabian Homborg
123676075f Add flog category for history *file* 2020-01-19 14:22:50 +01:00
Fabian Homborg
024e03ab1e Replace debug(1) with FLOGF(warning) 2020-01-19 14:22:39 +01:00
ridiculousfish
1978ac87a1 Remove reader_test_should_cancel
Use cancel_checker more pervasively.
2020-01-16 15:21:45 -08:00
ridiculousfish
f1ce967dfa Do not allow empty items to be added to history
Empty items are used as sentinels to indicate that we've reached the end of
history, so they should not be added as actual items. Enforce this.

Fixes #6032
2020-01-05 12:47:02 -08:00
ridiculousfish
65e9f31c7a Use autoclose_fd_t more pervasively in history 2020-01-01 13:49:10 -08:00
ridiculousfish
5aa22adccc Make history_filename return a maybe_t<wcstring>
This function can fail, so rather than forcing clients to check the return
value as empty, allow it to return none().
2020-01-01 12:34:42 -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
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
5ca80a61e3 [clang-tidy] Fix inconsistent declarations
Found with readability-inconsistent-declaration-parameter-name

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
ridiculousfish
7bd134f795 Reformat all .cpp files 2019-11-09 16:07:33 -08:00
Johannes Altmanninger
e94b9ccf3e Do import bash history commands containing && or || 2019-11-07 23:33:35 +01:00
Johannes Altmanninger
1cfa3fa819 Speed up import of bash history
Fixes #6295
2019-11-07 23:33:35 +01:00
ridiculousfish
47c0b5f931 Simplify history searching and fix deduplication
The history search logic had a not very useful "fast path" which was also
buggy because it neglected to dedup. Switch the "fast path" to just a
history search type which always matches.

Fixes #6278
2019-11-02 19:33:45 -07:00
ridiculousfish
52e900690b Make history_search_type_t an enum class 2019-11-02 18:56:16 -07:00
ridiculousfish
be35b858c5 Minor allocation reduction in format_history_record
Reuse some storage across calls.
2019-11-02 18:35:19 -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
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
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
99c498d3d7 Use move semantics in trim and history_item_t 2019-08-25 13:37:06 -07: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
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
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
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
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
bc0329f775 Add wcstolower
Converts a string to lowercase. Eliminates some loops that did this
explicitly.
2019-07-06 12:19:34 -07:00
ridiculousfish
3c800e0608 Make history tests more robust
history now often writes to the history file asynchronously, but the history
test expects to find the text in the file immediately after running the
command. Hack a bit in history to make this test more reliable.
2019-06-28 11:16:27 -07:00
ridiculousfish
360116221a Switch history_t to use owning_lock internally
This removes a lot of tricky manual locking. It also removes the "main
thread" dependency.
2019-06-14 20:49:17 -07:00
Fabian Homborg
d73ee4d54b More using FLOGF when formatting is needed
sed-patched, every time a "%" is used in a call to `FLOG`, we use
`FLOGF` instead.
2019-05-30 11:54:09 +02:00
David Adam
ba4f4bfce2 Convert further debug(0) calls to FLOG
Follow on from ea9d1ad82f.
2019-05-28 21:06:42 +08:00
ridiculousfish
ea9d1ad82f Convert debug(0) calls to FLOG 2019-05-27 17:31:17 -07:00
Fabian Homborg
87b93cd4ca src/history: Only widen bash history lines once
This did str2wcs when checking, then again when adding.
2019-05-14 09:49:51 +02:00
Fabian Homborg
2aaf7fda27 src/history: Stop renarrowing a string in a for-loop
Classic case of doing stuff in a loop that doesn't change. No idea if
the compiler caught it, but I sleep easier now.
2019-05-14 09:49:50 +02:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
ridiculousfish
36998eee55 Make more miscellaneous globals thread safe 2019-05-04 20:58:35 -07:00
ridiculousfish
6e143bf50f Eliminate history_collection_t
This was a pretty useless type.
2019-05-04 20:58:35 -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