aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-26 20:11:34 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-26 20:11:34 -0800
commitf74a82776f9a20f09149712d50cee557d8302ec0 (patch)
treec24d45936ba2d272035709f8dd7f8943cd24f5c8 /reader.cpp
parent3553e650891db84b3feffaef872d378c750f807b (diff)
Some more changes in preparation for turning on complete-based autosuggestions
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/reader.cpp b/reader.cpp
index 0f95672e..657e6bc3 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -1225,6 +1225,7 @@ struct autosuggestion_context_t {
file_detection_context_t detector;
const wcstring working_directory;
const env_vars vars;
+ wcstring_list_t commands_to_load;
autosuggestion_context_t(history_t *history, const wcstring &term) :
search_string(term),
@@ -1261,7 +1262,7 @@ struct autosuggestion_context_t {
/* Try normal completions */
std::vector<completion_t> completions;
- //complete2(search_string, completions, COMPLETE_AUTOSUGGEST);
+ //complete(search_string, completions, COMPLETE_AUTOSUGGEST, &this->commands_to_load);
if (! completions.empty()) {
this->autosuggestion = this->search_string;
this->autosuggestion.append(completions.at(0).completion);
@@ -1288,6 +1289,24 @@ static bool can_autosuggest(void) {
}
static void autosuggest_completed(autosuggestion_context_t *ctx, int result) {
+
+
+ /* Extract the commands to load */
+ wcstring_list_t commands_to_load;
+ ctx->commands_to_load.swap(commands_to_load);
+
+ /* If we have autosuggestions to load, load them and try again */
+ if (! result && ! commands_to_load.empty())
+ {
+ for (wcstring_list_t::const_iterator iter = commands_to_load.begin(); iter != commands_to_load.end(); iter++)
+ {
+ printf("loading %ls\n", iter->c_str());
+ complete_load(*iter, false);
+ }
+ iothread_perform(threaded_autosuggest, autosuggest_completed, ctx);
+ return;
+ }
+
if (result &&
can_autosuggest() &&
ctx->search_string == data->command_line &&
@@ -1296,7 +1315,6 @@ static void autosuggest_completed(autosuggestion_context_t *ctx, int result) {
data->autosuggestion = ctx->autosuggestion;
sanity_check();
reader_repaint();
-
}
delete ctx;
}
@@ -2838,7 +2856,7 @@ const wchar_t *reader_readline()
buffcpy = wcsndup( begin, len );
// comp = al_halloc( 0 );
- data->complete_func( buffcpy, comp, COMPLETE_DEFAULT );
+ data->complete_func( buffcpy, comp, COMPLETE_DEFAULT, NULL);
sort_completion_list( comp );
remove_duplicates( comp );